• clikhouse报错:DB::Exception: Storage MergeTree requires 3 to 4 parameters:


    Received exception from server (version 20.2.1):
    Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Storage MergeTree requires 3 to 4 parameters:
    name of column with date,
    [sampling element of primary key],
    primary key expression,
    index granularity

    MergeTree is a family of storage engines.

    MergeTrees are different in two ways:
    - they may be replicated and non-replicated;
    - they may do different actions on merge: nothing; sign collapse; sum; apply aggregete functions.

    So we have 14 combinations:
    MergeTree, CollapsingMergeTree, SummingMergeTree, AggregatingMergeTree, ReplacingMergeTree, GraphiteMergeTree, VersionedCollapsingMergeTree
    ReplicatedMergeTree, ReplicatedCollapsingMergeTree, ReplicatedSummingMergeTree, ReplicatedAggregatingMergeTree, ReplicatedReplacingMergeTree, ReplicatedGraphiteMergeTree, ReplicatedVersionedCollapsingMergeTree

    In most of cases, you need MergeTree or ReplicatedMergeTree.

    For replicated merge trees, you need to supply a path in ZooKeeper and a replica name as the first two parameters.
    Path in ZooKeeper is like '/clickhouse/tables/01/' where /clickhouse/tables/ is a common prefix and 01 is a shard name.
    Replica name is like 'mtstat01-1' - it may be the hostname or any suitable string identifying replica.
    You may use macro substitutions for these parameters. It's like ReplicatedMergeTree('/clickhouse/tables/{shard}/', '{replica}'...
    Look at the <macros> section in server configuration file.

    Next parameter (which is the first for unreplicated tables and the third for replicated tables) is the name of date column.
    Date column must exist in the table and have type Date (not DateTime).
    It is used for internal data partitioning and works like some kind of index.

    If your source data doesn't have a column of type Date, but has a DateTime column, you may add values for Date column while loading,
    or you may INSERT your source data to a table of type Log and then transform it with INSERT INTO t SELECT toDate(time) AS date, * FROM ...
    If your source data doesn't have any date or time, you may just pass any constant for a date column while loading.

    Next parameter is optional sampling expression. Sampling expression is used to implement SAMPLE clause in query for approximate query execution.
    If you don't need approximate query execution, simply omit this parameter.
    Sample expression must be one of the elements of the primary key tuple. For example, if your primary key is (CounterID, EventDate, intHash64(UserID)), your sampling expression might be intHash64(UserID).

    Next parameter is the primary key tuple. It's like (CounterID, EventDate, intHash64(UserID)) - a list of column names or functional expressions in round brackets. If your primary key has just one element, you may omit round brackets.

    Careful choice of the primary key is extremely important for processing short-time queries.

    Next parameter is index (primary key) granularity. Good value is 8192. You have no reasons to use any other value.

    For the Collapsing mode, the last parameter is the name of a sign column - a special column that is used to 'collapse' rows with the same primary key while merging.

    For the Summing mode, the optional last parameter is a list of columns to sum while merging. This list is passed in round brackets, like (PageViews, Cost).
    If this parameter is omitted, the storage will sum all numeric columns except columns participating in the primary key.

    For the Replacing mode, the optional last parameter is the name of a 'version' column. While merging, for all rows with the same primary key, only one row is selected: the last row, if the version column was not specified, or the last row with the maximum version value, if specified.

    For VersionedCollapsing mode, the last 2 parameters are the name of a sign column and the name of a 'version' column. Version column must be in primary key. While merging, a pair of rows with the same primary key and different sign may collapse.

    Examples:

    MergeTree(EventDate, (CounterID, EventDate), 8192)

    MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192)

    CollapsingMergeTree(StartDate, intHash32(UserID), (CounterID, StartDate, intHash32(UserID), VisitID), 8192, Sign)

    SummingMergeTree(EventDate, (OrderID, EventDate, BannerID, PhraseID, ContextType, RegionID, PageID, IsFlat, TypeID, ResourceNo), 8192)

    SummingMergeTree(EventDate, (OrderID, EventDate, BannerID, PhraseID, ContextType, RegionID, PageID, IsFlat, TypeID, ResourceNo), 8192, (Shows, Clicks, Cost, CostCur, ShowsSumPosition, ClicksSumPosition, SessionNum, SessionLen, SessionCost, GoalsNum, SessionDepth))

    ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/hits', '{replica}', EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID), EventTime), 8192)

    For further info please read the documentation: https://clickhouse.yandex/
    .

    0 rows in set. Elapsed: 0.174 sec.

    缺少参数 必须有分区参数:

  • 相关阅读:
    H5页面调用Android原生Activity方法
    如何解决Android studio错误“Unsupported Modules Detected: Compilation is not supported for following modules”?
    Android studio 报错Error:Internal error: (java.lang.ClassNotFoundException) com.google.wireless.android.sdk.stats.IntellijIndexingStats$Index
    Android studio 连接真机
    spring-cloud-gateway报错
    maven install 报错 Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
    datetimepicker如果在获得焦点的时候自动定位到日期上,TDateTimePicker自动焦点定位到年,TDateTimePicker自动焦点定位到月,TDateTimePicker自动焦点定位到日
    在WPS或Excel中多列合并成一列合并后中间加空格或-或逗号的写法,可参照以下方法,wps与excel操作与用法都相同
    sql 四舍五入保留两位小数
    [经验分享] windows2008服务器设置系统启动时程序自动运行
  • 原文地址:https://www.cnblogs.com/wqbin/p/13889733.html
Copyright © 2020-2023  润新知