建议为JSON输入创建Jolt规范

我目前有以下JSON输入

{
    "erp": "EBS","erp_versions": [
        "3","9","10"
    ],"memsql_info": {
        "columnstore_keys": [
            {
                "LEDGER_ID": {
                    "Pos": 1,"Shard_Key_Pos": 1
                }
            },{
                "CODE_COMBINATION_ID": {
                    "Pos": 2,"Shard_Key_Pos": 2
                }
            },{
                "CURRENCY_CODE": {
                    "Pos": 3,"Shard_Key_Pos": 3
                }
            },{
                "PERIOD_NAME": {
                    "Pos": 4,"Shard_Key_Pos": 4
                }
            },{
                "actUAL_flaG": {
                    "Pos": 5,"Shard_Key_Pos": 5
                }
            },{
                "BUDGET_VERSION_ID": {
                    "Pos": 6,"nullable": true
                }
            },{
                "ENCUMBRANCE_TYPE_ID": {
                    "Pos": 7,{
                "TRANSLATED_flaG": {
                    "Pos": 8,"nullable": true
                }
            }
        ],"reference_table": false,"shard_keys": [
            {
                "LEDGER_ID": {
                    "PKey_Pos": 1,"Pos": 1
                }
            },{
                "CODE_COMBINATION_ID": {
                    "PKey_Pos": 2,"Pos": 2
                }
            },{
                "CURRENCY_CODE": {
                    "PKey_Pos": 3,"Pos": 3
                }
            },{
                "PERIOD_NAME": {
                    "PKey_Pos": 4,"Pos": 4
                }
            },{
                "actUAL_flaG": {
                    "PKey_Pos": 5,"Pos": 5
                }
            }
        ]
    },"primary_keys": [
        {
            "LEDGER_ID": {
                "Pos": 1,"Shard_Key_Pos": 1
            }
        },{
            "CODE_COMBINATION_ID": {
                "Pos": 2,"Shard_Key_Pos": 2
            }
        },{
            "CURRENCY_CODE": {
                "Pos": 3,"Shard_Key_Pos": 3
            }
        },{
            "PERIOD_NAME": {
                "Pos": 4,"Shard_Key_Pos": 4
            }
        },{
            "actUAL_flaG": {
                "Pos": 5,"Shard_Key_Pos": 5
            }
        },{
            "BUDGET_VERSION_ID": {
                "Pos": 6,"nullable": true
            }
        },{
            "ENCUMBRANCE_TYPE_ID": {
                "Pos": 7,{
            "TRANSLATED_flaG": {
                "Pos": 8,"nullable": true
            }
        }
    ],"queries": [
        {
            "erp_versions": [],"legacy_repo_name": [
                "ecf_template_ebs_GL_BAlanceS_GM_XDM","ecf_template_ebs_GL_BAlanceS_GM","JOURNALS_TEMPLATE_EBS_12","JOURNALS_TEMPLATE_EBS"
            ],"query_desc": "TBC","query_id": "3736e3fc-e9c9-4df2-95e2-bc1c0103a86f","query_json": {
                "base_table": "GL_BAlanceS","filters": [
                    {
                        "interpretation": "STRICT","field": "actUAL_flaG","operation": "=","operator": "AND","data_type": "text","values": [
                            "A"
                        ]
                    },{
                        "interpretation": "ITER","field": "PERIOD_YEAR","operation": "IN","data_type": "integer","values": [
                            "&&PERIOD_FISCAL_YEAR"
                        ]
                    },"field": "LEDGER_ID","operator": "","values": [
                            "&&LEDGER_ID"
                        ]
                    }
                ],"distinct": false,"joins": []
            }
        },{
            "erp_versions": [],"legacy_repo_name": [],"query_id": "bce22847-d297-4232-8ecb-bcd26dfaa9bd","values": [
                            "&&PERIOD_FISCAL_YEAR%-1"
                        ]
                    },"joins": []
            }
        }
    ],"schema_owner": "GL","table_desc": "GL_BAlanceS stores actual,budget,and encumbrance balances for detail and summary accounts. This table stores ledger currency,foreign currency,and statistical balances for each accounting period that has ever been opened. actUAL_flaG is either 'A','B',or 'E' for actual,or encumbrance balances,respectively. If actUAL_flaG is 'B',then BUDGET_VERSION_ID is required. If actUAL_flaG is 'E',then ENCUMBRANCE_TYPE_ID is required. GL_BAlanceS stores period activity for an account in the PERIOD_NET_DR and PERIOD_NET_CR columns. The table stores the period beginning balances in BEGIN_BAlance_DR and BEGIN_BAlance_CR. An account's year-to-date balance is calculated as BEGIN_BAlance_DR - BEGIN_BAlance_CR + PERIOD_NET_DR - PERIOD_NET_CR. Detail and summary foreign currency balances that are the result of posted foreign currency journal entries have TRANSLATED_flaG set to 'R',to indicate that the row is a candidate for revaluation.","table_name": "GL_BAlanceS","query_fields": {
        "BEGIN_BAlance_DR": {
            "data_type": "NUMber","length": 22,"precision": 0,"scale": -127,"nullable": 1
        },"TEMPLATE_ID": {
            "data_type": "NUMber","precision": 15,"scale": 0,"ENCUMBRANCE_TYPE_ID": {
            "data_type": "NUMber","LEDGER_ID": {
            "data_type": "NUMber","nullable": 0
        },"BUDGET_VERSION_ID": {
            "data_type": "NUMber","TRANSLATED_flaG": {
            "data_type": "STRING","length": 1,"PERIOD_NAME": {
            "data_type": "STRING","length": 15,"PERIOD_YEAR": {
            "data_type": "NUMber","PERIOD_NUM": {
            "data_type": "NUMber","BEGIN_BAlance_CR": {
            "data_type": "NUMber","CURRENCY_CODE": {
            "data_type": "STRING","PERIOD_NET_CR": {
            "data_type": "NUMber","CODE_COMBINATION_ID": {
            "data_type": "NUMber","actUAL_flaG": {
            "data_type": "STRING","PERIOD_NET_DR": {
            "data_type": "NUMber","nullable": 1
        }
    },"version_columns": {
        "3": {},"9": {},"10": {}
    }
}

,我想产生以下JSON输出

{
    "type": "record","name": "GL_BAlanceS","fields": [
        {
            "name": "BEGIN_BAlance_DR","type": [
                "null",{
                    "type": "number"
                }
            ]
        },{
            "name": "TEMPLATE_ID",{
                    "type": "number","precision": 15
                }
            ]
        },{
            "name": "ENCUMBRANCE_TYPE_ID","type": {
                "type": "number","precision": 15
            }
        },{
            "name": "LEDGER_ID",{
            "name": "BUDGET_VERSION_ID","precision": 22
            }
        },{
            "name": "TRANSLATED_flaG","type": "string"
        },{
            "name": "PERIOD_NAME",{
            "name": "PERIOD_YEAR",{
            "name": "PERIOD_NUM",{
            "name": "BEGIN_BAlance_CR",{
            "name": "CURRENCY_CODE",{
            "name": "PERIOD_NET_CR",}
            ]
        },{
            "name": "CODE_COMBINATION_ID",{
            "name": "actUAL_flaG",{
            "name": "PERIOD_NET_DR",{
                    "type": "number"
                }
            ]
        }
    ]
}

我已经提出了以下规格,但我找不到其余的

[
  {
    "operation": "shift","spec": {
      "#record": "type","#GL_BAlanceS": "name","query_fields": {
        "*": {
          "$": "fields[#2].name","nullable": { "1": { "#null": "fields[#4].type[]" } },"data_type": "fields[#2].type[].type","precision": "fields[#2].type[].precision","scale": "fields[#2].type[].scale"
        }
      }
    }
  }
]

给出

{
  "type" : "record","name" : "GL_BAlanceS","fields" : [ {
    "name" : "BEGIN_BAlance_DR","type" : [ "null",{
      "type" : "NUMber"
    },{
      "precision" : 0
    },{
      "scale" : -127
    } ]
  },{
    "name" : "TEMPLATE_ID",{
      "precision" : 15
    },{
      "scale" : 0
    } ]
  },{
    "name" : "ENCUMBRANCE_TYPE_ID",{
    "name" : "LEDGER_ID","type" : [ {
      "type" : "NUMber"
    },{
    "name" : "BUDGET_VERSION_ID",{
    "name" : "TRANSLATED_flaG",{
      "type" : "STRING"
    },{
    "name" : "PERIOD_NAME","type" : [ {
      "type" : "STRING"
    },{
    "name" : "PERIOD_YEAR",{
    "name" : "PERIOD_NUM",{
    "name" : "BEGIN_BAlance_CR",{
    "name" : "CURRENCY_CODE",{
    "name" : "PERIOD_NET_CR",{
    "name" : "CODE_COMBINATION_ID",{
    "name" : "actUAL_flaG",{
    "name" : "PERIOD_NET_DR",{
      "scale" : -127
    } ]
  } ]
}

仅当precisionscale大于0并展平type字典时,我才想显示它们。我需要声明其他规格吗?目标是能够为我的NiFi流程生成Avro模式。

wolaiwen_0 回答:建议为JSON输入创建Jolt规范

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3099481.html

大家都在问