Error: Query schema does not match table schema. QuerySchema=('long')

Error: Query schema does not match table schema. QuerySchema=('long')

我是 运行 一个 .set-or-append 命令,用于从 1 table 摄取到另一个。我知道来自源 table 的查询很好,目标 table 如果存在,应该有相同的查询,但如果不存在,命令应该只创建它。最初我对此没有问题。但是我的一些 .set-or-append 查询出现了这个错误:

Invalid query for distributed set / append / replace operation. Error: Query schema does not match table schema. QuerySchema=('long'), TableSchema=('datetime,string,string,string,string,dynamic,dynamic,dynamic'). Query:...'

我知道这些模式是匹配的。我 运行 一次又一次地执行相同的命令,大约在第 3 次尝试调用成功。这对我来说是 0 意义。那么上面的错误是什么?为什么相同的命令在失败后仍然有效,而查询没有任何变化?

我是运行的query/command本质上是这样的:

.set-or-append async TargetTable <|
SourceTable
| where __id in ("...", "....", ........) // is aproximately 250 distinct ids in "in" operator

您使用的查询似乎正在使用额外的列扩展数据: extend hashBucket = hash(row_number(), ...) | where hashBucket == ... - 因此你会得到架构不匹配。

也许,你的意图是基于hashBucket进行过滤,在这种情况下你可以直接使用不带扩展名的过滤: where hash(row_number(), ...) == ...

Yoni 你能解释一下 bag_unpack 给出不一致的不匹配是什么意思吗?我对齐我的 bag_unpack ... project-reorder 以匹配我要解包的目标 table,但它只是围绕错误消息中的几个变量类型进行了更改:

    Query schema does not match table schema. 
    QuerySchema=(
    'datetime,long,datetime,string,string,datetime,string,
    long,real,string,bool,guid,guid,string,real'), 
    TableSchema=(
    'datetime,long,datetime,string,string,datetime,string,
    long,real,guid,guid,string,bool,string,real')

此时甚至对 table 模式和查询模式感到困惑。


作为参考,我的查询是这样的:

    .set-or-append async apiV2FormationSearchTransform <|
    //set notruncation;
    apiV2FormationSearchLatest
    | where hash(toguid(fullRecord["id"]), 1) == 0
    | project fullRecord
    | evaluate bag_unpack(fullRecord)
    | extend dateCatalogued = todatetime(column_ifexists("dateCatalogued", ""))
    , simpleId = tolong(column_ifexists("simpleId", ""))
    , dateLastModified = todatetime(column_ifexists("dateLastModified", ""))
    , reportedFormationName = tostring(column_ifexists("reportedFormationName", ""))
    , comments = tostring(column_ifexists("comments", ""))
    , dateCreated = todatetime(column_ifexists("dateCreated", ""))
    , formationName = tostring(column_ifexists("formationName", ""))
    , internalId = tolong(column_ifexists("internalId", ""))
    , topDepth = toreal(column_ifexists("topDepth", ""))
    , wellId = column_ifexists("wellId", toguid(""))
    , id = column_ifexists("id", toguid(""))
    , methodObtained = tostring(column_ifexists("methodObtained", ""))
    , isTarget = tobool(column_ifexists("isTarget", ""))
    , completionId = tostring(column_ifexists("completionId", ""))
    , baseDepth = toreal(column_ifexists("baseDepth", ""))

    | project-reorder dateCatalogued
    , simpleId
    , dateLastModified
    , reportedFormationName
    , comments
    , dateCreated
    , formationName
    , internalId
    , topDepth
    , wellId
    , id
    , methodObtained
    , isTarget
    , completionId
    , baseDepth

这是我的目标 table:

getschema 输出
    dateCatalogued          0   System.DateTime datetime
    simpleId                1   System.Int64    long
    dateLastModified        2   System.DateTime datetime
    reportedFormationName   3   System.String   string
    comments                4   System.String   string
    dateCreated             5   System.DateTime datetime
    formationName           6   System.String   string
    internalId              7   System.Int64    long
    topDepth                8   System.Double   real
    wellId                  9   System.Guid guid
    id                      10  System.Guid guid
    methodObtained          11  System.String   string
    isTarget                12  System.SByte    bool
    completionId            13  System.String   string
    baseDepth               14  System.Double   real