铸造厂 Palantir – TypeScript 函数:更新列上的数值

huangapple go评论52阅读模式
英文:

Foundry Palantir - Typescript function : update valeur on columns

问题

@OntologyEditFunction()
public async deletevaluetable(
    objectpart: ObjectPartsNew[],
    ID?: string,
    level?: string,
    responsible?: string,
    description?: string,
): Promise<void> {
    function deletevaluetable() {
        var manual;
        for (var i = 0; i < objectpart.length; i++) {
            manual = objectpart[i];
            var updates = 0;
            const properties_dict: manualUpdate = {
                "manual": ID,
            };
            .....
        }
    }
}
英文:

I will like a help for a typescript function on ontology object.
I would like to write a typescript program that takes a dataframe as input.
When I remove a value from a row in a column, the values in other columns change to null.

For example, this a dataframe

ID level responsible description
A12 level2 NG34Jean Sheet
B15 level5 NG90Elis Bellow
C67 level4 NG64Matire Clamp
H65 level3 NG45Louis Cubical
J90 level0 NG08Marie Blech
For the ID = B15, I would like to remove its level ie &quot;level5&quot; hence the values of &quot;responsible&quot; and &quot;description&quot; egal to &quot;Null&quot;

For the ID = H65, I would like to remove its level ie &quot;level3&quot; hence the values of &quot;responsible&quot; and &quot;description&quot; egal to &quot;Null&quot;

Here is the dataframe at the end

ID level responsible description
A12 level2 NG34Jean Sheet
B15 No value null null
C67 level4 NG64Matire Clamp
H65 No value null null
J90 level0 NG08Marie Blech
@OntologyEditFunction()
    public async deletevaluetable(
        objectpart: ObjectPartsNew[],
        ID?: string,
        level?: string,
        responsible?: string,
        description?: string,
    ): Promise&lt;void&gt; {
        function deletevaluetable()  {
            var manual;
            for (var i = 0; i &lt; objectpart.length; i++) {
                manual=objectpart[i];
                var updates = 0;
                const properties_dict: manualUpdate = {
                    &quot;manual&quot;: ID, 
                };
                .....
            }   
        }
    }

答案1

得分: 1

我认为你可能混淆了一些概念,例如编辑本体不是一个Spark任务,因此没有数据框架。你直接在实时搜索和索引系统中操作单个对象实体。你有没有可能展示一下实际执行这些更改的代码呢?我怀疑你可能只是用新的实体覆盖了之前的实体,并且减少了一些列。

即,你可能想要这样做:

const editedObjectProperties: ObjectPartsNew = {
    ID: ID, 
    level: "No value",
    responsible: objectpart[i].responsible,
    description: objectpart[i].description
};
英文:

I think you are confusing some concepts, for example editing the ontology is not a spark job, thus there are no dataframes. You're directly manipulating an individual objects entity in a real time search and indexing system. Any chance you can show the code that actually performs the changes? I have a suspicion you are just overwriting the previous entity with a new one with less columns.

i.e. instead of this:

   manual=objectpart[i];
   var updates = 0;
   const properties_dict: manualUpdate = {
       &quot;manual&quot;: ID, 
   };

You probably want:

   const editedObjectProperties: ObjectPartsNew = {
       ID: ID, 
       level: &quot;No value&quot;,
       responsible: objectpart[i].responsible,
       description: objectpart[i].description
   };

huangapple
  • 本文由 发表于 2023年2月14日 03:20:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440357.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定