Skip to content

fix(alicloud)!: Add billing_date and instance_id to alicloud_bss_bill_details primary key#9639

Merged
kodiakhq[bot] merged 24 commits into
cloudquery:mainfrom
easayliu:main
Apr 4, 2023
Merged

fix(alicloud)!: Add billing_date and instance_id to alicloud_bss_bill_details primary key#9639
kodiakhq[bot] merged 24 commits into
cloudquery:mainfrom
easayliu:main

Conversation

@easayliu
Copy link
Copy Markdown
Contributor

@easayliu easayliu commented Apr 3, 2023

Summary

@easayliu easayliu requested review from a team and candiduslynx and removed request for a team April 3, 2023 10:32
@cq-bot cq-bot added the alicloud label Apr 3, 2023
@candiduslynx candiduslynx changed the title fix(alicloud): error duplicate primary key. fix(alicloud)!: Fix duplicate primary key in alicloud_bss_bill_details Apr 3, 2023
@candiduslynx
Copy link
Copy Markdown
Contributor

@easayliu you would also need to run make gen-docs in the plugin dir & commit the changed table docs, too

@cq-bot cq-bot added the website label Apr 4, 2023
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2023

This PR has the following changes to source plugin(s) tables:

  • ⚠️ BREAKING CHANGE: Table alicloud_bss_bill_details: primary key constraint added to column billing_date
  • ⚠️ BREAKING CHANGE: Table alicloud_bss_bill_details: primary key constraint added to column instance_id

@easayliu easayliu closed this Apr 4, 2023
@easayliu easayliu reopened this Apr 4, 2023
@candiduslynx candiduslynx changed the title fix(alicloud)!: Fix duplicate primary key in alicloud_bss_bill_details fix(alicloud)!: Add billing_date and instance_id to alicloud_bss_bill_details primary key Apr 4, 2023
@candiduslynx candiduslynx added the automerge Automatically merge once required checks pass label Apr 4, 2023
@candiduslynx
Copy link
Copy Markdown
Contributor

@easayliu thanks once again for the PR!
We also noticed some similar issues with the following tables:

  • alicloud_bss_bill
  • alicloud_bss_bill_overview

Would you mind taking look at them, too? (asking as you clearly have much more experience with AliCloud than us)

kodiakhq Bot pushed a commit that referenced this pull request Apr 4, 2023
🤖 I have created a release *beep* *boop*
---


## [2.0.0](plugins-source-alicloud-v1.2.0...plugins-source-alicloud-v2.0.0) (2023-04-04)


### ⚠ BREAKING CHANGES

* **alicloud:** Add `billing_date` and `instance_id` to `alicloud_bss_bill_details` primary key ([#9639](#9639))

### This Release has the Following Changes to Tables
- Table `alicloud_bss_bill_details`: primary key constraint added to column `billing_date` (:warning: breaking)
- Table `alicloud_bss_bill_details`: primary key constraint added to column `instance_id` (:warning: breaking)
- Table `alicloud_ecs_instances`: column added with name `instance_owner_id` and type `Int`

### Bug Fixes

* **alicloud:** Add `billing_date` and `instance_id` to `alicloud_bss_bill_details` primary key ([#9639](#9639)) ([c68cf92](c68cf92))
* **deps:** Update golang.org/x/exp digest to 10a5072 ([#9587](#9587)) ([31f913f](31f913f))
* **deps:** Update module github.com/aliyun/alibaba-cloud-sdk-go to v1.62.266 ([#9601](#9601)) ([f7135db](f7135db))
* **deps:** Update module github.com/aliyun/aliyun-oss-go-sdk to v2.2.7 ([#9602](#9602)) ([81f1cb7](81f1cb7))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.44.1 ([#9520](#9520)) ([202c31b](202c31b))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.44.2 ([#9661](#9661)) ([a27dc84](a27dc84))
* **deps:** Update module github.com/mattn/go-isatty to v0.0.18 ([#9609](#9609)) ([5b2908e](5b2908e))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
@easayliu
Copy link
Copy Markdown
Contributor Author

easayliu commented Apr 6, 2023

@easayliu thanks once again for the PR! We also noticed some similar issues with the following tables:

  • alicloud_bss_bill
  • alicloud_bss_bill_overview

Would you mind taking look at them, too? (asking as you clearly have much more experience with AliCloud than us)

i will check this .

@easayliu
Copy link
Copy Markdown
Contributor Author

easayliu commented Apr 6, 2023

@easayliu thanks once again for the PR! We also noticed some similar issues with the following tables:

  • alicloud_bss_bill
  • alicloud_bss_bill_overview

Would you mind taking look at them, too? (asking as you clearly have much more experience with AliCloud than us)

Replay with my accout, i get the same duplicate primary key.
we will purchase multiple resource packs in one order, so we get duplicate primary key at table alicloud_bss_bill_overview.
in table alicloud_bs_bill,this issue will occur when refunding.
This one is good to resolve, add pk item. but the alicloud_bss_bill_overview is hard to say, this one is get the same value in every key.
Do you have any suggestions?
for example

{
  "Message": "Successful!",
  "RequestId": "AFBE3713-8CF3-5001-BD01-CF8372761D0C",
  "Data": {
    "BillingCycle": "2023-03",
    "TotalCount": 3,
    "AccountID": "XX",
    "PageNum": 1,
    "PageSize": 20,
    "Items": {
      "Item": [
        {
          "ProductName": "消息队列 MQ",
          "SubOrderId": "XX",
          "DeductedByCashCoupons": 0,
          "PaymentTime": "2023-03-14 18:20:47",
          "PaymentAmount": 20088.68,
          "DeductedByPrepaidCard": 0,
          "InvoiceDiscount": 3600,
          "UsageEndTime": "",
          "Item": "SubscriptionOrder",
          "SubscriptionType": "Subscription",
          "PretaxGrossAmount": 24000,
          "Currency": "CNY",
          "CommodityCode": "onsbag",
          "UsageStartTime": "",
          "AdjustAmount": 0,
          "Status": "PayFinish",
          "DeductedByCoupons": 311.32,
          "RoundDownDiscount": 0,
          "ProductDetail": "RocketMQ 4.0 标准版专用资源包(容量递减)",
          "ProductCode": "ons",
          "ProductType": "",
          "OutstandingAmount": 0,
          "PipCode": "ons",
          "PretaxAmount": 20088.68,
          "OwnerID": "XX",
          "RecordID": "XX",
          "CashAmount": 20088.68
        },
        {
          "ProductName": "消息队列 MQ",
          "SubOrderId": "XX",
          "DeductedByCashCoupons": 0,
          "PaymentTime": "2023-03-14 18:20:47",
          "PaymentAmount": 20088.68,
          "DeductedByPrepaidCard": 0,
          "InvoiceDiscount": 3600,
          "UsageEndTime": "",
          "Item": "SubscriptionOrder",
          "SubscriptionType": "Subscription",
          "PretaxGrossAmount": 24000,
          "Currency": "CNY",
          "CommodityCode": "onsbag",
          "UsageStartTime": "",
          "AdjustAmount": 0,
          "Status": "PayFinish",
          "DeductedByCoupons": 311.32,
          "RoundDownDiscount": 0,
          "ProductDetail": "RocketMQ 4.0 标准版专用资源包(容量递减)",
          "ProductCode": "ons",
          "ProductType": "",
          "OutstandingAmount": 0,
          "PipCode": "ons",
          "PretaxAmount": 20088.68,
          "OwnerID": "XX",
          "RecordID": "XX",
          "CashAmount": 20088.68
        },
        {
          "ProductName": "消息队列 MQ",
          "SubOrderId": "XX",
          "DeductedByCashCoupons": 0,
          "PaymentTime": "2023-03-14 18:20:47",
          "PaymentAmount": 12580.54,
          "DeductedByPrepaidCard": 0,
          "InvoiceDiscount": 2254.5,
          "UsageEndTime": "",
          "Item": "SubscriptionOrder",
          "SubscriptionType": "Subscription",
          "PretaxGrossAmount": 15030,
          "Currency": "CNY",
          "CommodityCode": "onsbag",
          "UsageStartTime": "",
          "AdjustAmount": 0,
          "Status": "PayFinish",
          "DeductedByCoupons": 194.96,
          "RoundDownDiscount": 0,
          "ProductDetail": "RocketMQ 4.0 标准版专用资源包(容量递减)",
          "ProductCode": "ons",
          "ProductType": "",
          "OutstandingAmount": 0,
          "PipCode": "ons",
          "PretaxAmount": 12580.54,
          "OwnerID": "XX",
          "RecordID": "XX",
          "CashAmount": 12580.54
        }
      ]
    },
    "AccountName": "XX"
  },
  "Code": "Success",
  "Success": true
}

@candiduslynx
Copy link
Copy Markdown
Contributor

@easayliu thanks for looking into the possible PK issues!

Would you mind creating a PR for alicloud_bs_bill with item added to the primary key? (that way we can keep the acknowledgement that it was your valuable input on the issue)

For the alicloud_bss_bill_overview issue:
We now have (billing_cycle,account_id,subscription_type,commodity_code,product_code,product_type,pip_code,record_id) as the PK.
I see that there are owner_id and sub_order_id fields that might also provide additional uniqueness to the bill overview.

Would you mind testing with jq?
Something like:

cat output.json | jq -S -c '.Data.Items.Item[] | { SubscriptionType, CommodityCode, ProductCode, ProductType, PipCode, RecordID, OwnerID, SubOrderId }' | wc -l
cat output.json | jq -S -c '.Data.Items.Item[] | { SubscriptionType, CommodityCode, ProductCode, ProductType, PipCode, RecordID, OwnerID, SubOrderId }' | sort | uniq | wc -l

If the numbers are the same, it means that the uniqueness key is enough.

@easayliu
Copy link
Copy Markdown
Contributor Author

easayliu commented May 4, 2023

@easayliu thanks for looking into the possible PK issues!

Would you mind creating a PR for alicloud_bs_bill with item added to the primary key? (that way we can keep the acknowledgement that it was your valuable input on the issue)

For the alicloud_bss_bill_overview issue: We now have (billing_cycle,account_id,subscription_type,commodity_code,product_code,product_type,pip_code,record_id) as the PK. I see that there are owner_id and sub_order_id fields that might also provide additional uniqueness to the bill overview.

Would you mind testing with jq? Something like:

cat output.json | jq -S -c '.Data.Items.Item[] | { SubscriptionType, CommodityCode, ProductCode, ProductType, PipCode, RecordID, OwnerID, SubOrderId }' | wc -l
cat output.json | jq -S -c '.Data.Items.Item[] | { SubscriptionType, CommodityCode, ProductCode, ProductType, PipCode, RecordID, OwnerID, SubOrderId }' | sort | uniq | wc -l

If the numbers are the same, it means that the uniqueness key is enough.

I`m sorry too late to reply this.
In that example, i remove number to protect.
OwnerID and RecordID is same number, It is not be able to be a PK.
Because this is order by same owner in same record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants