Memigrasikan laporan terlaris

Dokumen ini membantu Anda bermigrasi dari laporan item terlaris versi lama ke versi yang lebih baru. Versi lama laporan yang mengekspor tabel BestSellers_TopBrands_, BestSellers_TopProducts_, dan BestSellers_TopProducts_Inventory_ tidak akan digunakan lagi mulai 1 September 2025.

Laporan terlaris baru menawarkan hal berikut:

Tabel yang diekspor oleh laporan lama dan baru

Tabel berikut membandingkan tabel yang diekspor oleh laporan lama dan baru:

Laporan lama Laporan baru
BestSellers_TopBrands BestSellersBrandWeekly dan BestSellersBrandMonthly
BestSellers_TopProducts BestSellersProductClusterWeekly dan BestSellersProductClusterMonthly
BestSellers_TopProducts_Inventory BestSellersEntityProductMapping

Laporan lama berisi satu agregasi data terlaris selama jangka waktu yang tidak ditentukan. Laporan baru ini memberikan agregasi data ini terbaru mingguan dan bulanan pada saat permintaan.

Bandingkan BestSellers_TopBrands dengan BestSellersBrandWeekly dan BestSellersBrandMonthly

Tabel berikut membantu Anda mengidentifikasi kolom di tabel BestSellers_TopBrands yang memiliki pengganti yang setara di tabel BestSellersBrandWeekly dan BestSellersBrandMonthly. Penggantian untuk beberapa kolom dari tabel lama tidak tersedia.

BestSellers_TopBrands (lama) BestSellersBrandWeekly dan BestSellersBrandMonthly (baru)
rank_timestamp _PARTITIONDATE dan _PARTITIONTIME
brand brand
google_brand_id
ranking_category category_id
ranking_category_path.locale
ranking_category_path.name
ranking_country country_code
rank_id
rank rank
previous_rank previous_rank
relative_demand.bucket relative_demand
relative_demand.min
relative_demand.max
previous_relative_demand.bucket previous_relative_demand
previous_relative_demand.min
previous_relative_demand.max
relative_demand_change

Bandingkan BestSellers_TopProducts dengan BestSellersProductClusterWeekly dan BestSellersProductClusterMonthly

Tabel berikut membantu Anda mengidentifikasi kolom di tabel BestSellers_TopProducts yang memiliki pengganti yang setara di tabel BestSellersProductClusterWeekly dan BestSellersProductClusterMonthly. Penggantian untuk beberapa kolom dari tabel lama tidak tersedia.

BestSellers_TopProducts (lama) BestSellersProductClusterWeekly dan BestSellersProductClusterMonthly (baru)
rank_timestamp _PARTITIONDATE dan _PARTITIONTIME
rank_id entity_id
rank rank
previous_rank previous_rank
ranking_country country_code
ranking_category report_category_id
ranking_category_path.locale
ranking_category_path.name
relative_demand.bucket relative_demand
relative_demand.min
relative_demand.max
previous_relative_demand.bucket previous_relative_demand
previous_relative_demand.min
previous_relative_demand.max
relative_demand_change
product_title.locale
product_title.name title (satu judul, bukan array untuk setiap lokalitas)
gtins variant_gtins
google_brand_id
brand brand
google_product_category
category_l1, category_l2, category_l3, category_l4, category_l5
google_product_category_path.locale
google_product_category_path.name
price_range.min price_range.min_amount_micros
price_range.max price_range.max_amount_micros
price_range.currency price_range.currency_code
product_inventory_status
brand_inventory_status

Pemetaan inventaris data terlaris

Dalam laporan terlaris lama, data terlaris dipetakan ke data inventaris penjual dalam tabel yang dibuat baru, menggunakan kolom rank_id dari tabel TopProducts.

Dalam laporan terlaris baru, kolom entity_id diekspor dalam tabel BestSellersProductCluster, yang dipetakan ke semua ID produk dari inventaris penjual di tabel BestSellersEntityProductMapping.

BestSellers_TopProductsInventory (lama) BestSellersEntityProductMapping (baru)
rank_id (ditemukan di BestSellers_TopProducts) entity_id (ditemukan di tabel BestSellersProductClustersWeekly dan BestSellersProductClustersMonthly)
product_id product_id
merchant_id
aggregator_id

Contoh kueri

Bagian ini menyoroti perubahan pada contoh kueri yang digunakan untuk mengambil data terlaris.

Contoh 1: Mengambil produk teratas untuk kategori dan negara tertentu

Kueri berikut menampilkan produk teratas untuk kategori dan negara tertentu.

Menggunakan tabel BestSellers_TopProducts (lama)

SELECT
  rank,
  previous_rank,
  relative_demand.bucket,
  (SELECT name FROM top_products.product_title WHERE locale = 'en-US') AS product_title,
  brand,
  price_range,
  google_product_category
FROM
  `DATASET.BestSellers_TopProducts_MERCHANT_ID` AS top_products
WHERE
  _PARTITIONDATE = 'DATE' AND
  ranking_category = 267 /*Smartphones*/ AND
  ranking_country = 'US'
ORDER BY
  rank;

Menggunakan tabel BestSellersProductClusterWeekly atau BestSellersProductClusterMonthly (baru)

SELECT
  rank,
  previous_rank,
  relative_demand,
  title AS product_title,
  brand,
  price_range,
  category_l1,
  category_l2
FROM
  `DATASET.BestSellersProductClusterWeekly_MERCHANT_ID` AS top_products
WHERE
  _PARTITIONDATE = 'DATE' AND
  report_category_id = 267 /*Smartphones*/ AND
  country_code = 'US'
ORDER BY
  rank;

Contoh 2: Mengambil produk teratas dalam inventaris Anda

Kueri berikut menampilkan daftar produk teratas dalam inventaris Anda.

Menggunakan tabel BestSellers_TopProducts (lama)

WITH latest_top_products AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellers_TopProducts_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
),
latest_top_products_inventory AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellers_TopProducts_Inventory_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
)
SELECT
  top_products.rank,
  inventory.product_id,
  (SELECT ANY_VALUE(name) FROM top_products.product_title) AS product_title,
  top_products.brand,
  top_products.gtins
FROM
  latest_top_products AS top_products
INNER JOIN
  latest_top_products_inventory AS inventory
USING (rank_id);

Menggunakan tabel BestSellersProductClusterWeekly atau BestSellersProductClusterMonthly (baru)

WITH latest_top_products AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellersProductClusterWeekly_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
),
latest_top_products_inventory AS
(
  SELECT
    *
  FROM
    `DATASET.BestSellersEntityProductMapping_MERCHANT_ID`
  WHERE
    _PARTITIONDATE = 'DATE'
)
SELECT
  top_products.rank,
  inventory.product_id,
  top_products.title AS product_title,
  top_products.brand,
  top_products.variant_gtins
FROM
  latest_top_products AS top_products
INNER JOIN
  latest_top_products_inventory AS inventory
USING (entity_id);

Selain itu, jika Anda ingin menemukan jumlah produk atau merek terlaris di inventaris, jalankan kueri pada tabel BestSellerProductClusterWeekly atau BestSellerProductClusterMonthly menggunakan kolom product_inventory_status atau brand_inventory_status. Lihat contoh kueri berikut:

SELECT
  *
FROM
  `DATASET.BestSellersProductClusterMonthly_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  product_inventory_status != 'NOT_IN_INVENTORY'
ORDER BY
  rank;

Contoh 3: Mengambil merek teratas untuk kategori dan negara tertentu

Kueri berikut menampilkan daftar merek teratas untuk kategori dan negara tertentu.

Menggunakan tabel BestSellers_TopBrands (lama)

SELECT
  rank,
  previous_rank,
  brand
FROM
  `DATASET.BestSellers_TopBrands_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  ranking_category = 267 /*Smartphones*/ AND
  ranking_country = 'US'
ORDER BY
  rank;

Menggunakan tabel BestSellersTopBrandsWeekly atau BestSellersTopBrandsMonthly (baru)

SELECT
  rank,
  previous_rank,
  brand
FROM
  `DATASET.BestSellersTopBrandsWeekly_MERCHANT_ID`
WHERE
  _PARTITIONDATE = 'DATE' AND
  report_category_id = 267 /*Smartphones*/ AND
  country_code = 'US'
ORDER BY
  rank;

Contoh 4: Mengambil produk dari merek teratas dalam inventaris Anda

Kueri berikut menampilkan daftar produk dari merek teratas dalam inventaris Anda.

Menggunakan tabel BestSellers_TopBrands (lama)

WITH latest_top_brands AS
  (
    SELECT
      *
    FROM
      `DATASET.BestSellers_TopBrands_MERCHANT_ID`
    WHERE
      _PARTITIONDATE = 'DATE'
  ),
  latest_products AS
  (
    SELECT
      product.*,
      product_category_id
    FROM
      `DATASET.Products_MERCHANT_ID` AS product,
      UNNEST(product.google_product_category_ids) AS product_category_id,
      UNNEST(destinations) AS destination,
      UNNEST(destination.approved_countries) AS approved_country
    WHERE
      _PARTITIONDATE = 'DATE'
  )
SELECT
  top_brands.brand,
  (SELECT name FROM top_brands.ranking_category_path
  WHERE locale = 'en-US') AS ranking_category,
  top_brands.ranking_country,
  top_brands.rank,
  products.product_id,
  products.title
FROM
  latest_top_brands AS top_brands
INNER JOIN
  latest_products AS products
ON top_brands.google_brand_id = products.google_brand_id AND
   top_brands.ranking_category = product_category_id AND
   top_brands.ranking_country = products.approved_country;

Menggunakan tabel BestSellersTopBrandsWeekly atau BestSellersTopBrandsMonthly (baru)

WITH latest_top_brands AS
  (
    SELECT
      *
    FROM
      `DATASET.BestSellersBrandMonthly_MERCHANT_ID`
    WHERE
      _PARTITIONDATE = 'DATE'
  ),
  latest_products AS
  (
    SELECT
      product.*,
      product_category_id
    FROM
      `DATASET.Products_MERCHANT_ID` AS product,
      UNNEST(product.google_product_category_ids) AS product_category_id,
      UNNEST(destinations) AS destination,
      UNNEST(destination.approved_countries) AS approved_country
    WHERE
      _PARTITIONDATE = 'DATE'
  )
SELECT
  top_brands.brand,
  - The full category name is not supported in the new BestSellersTopBrands tables.
  - (SELECT name FROM top_brands.ranking_category_path
  - WHERE locale = 'en-US') AS ranking_category,
  top_brands.category_id,
  top_brands.rank,
  products.product_id,
  products.title
FROM
  latest_top_brands AS top_brands
INNER JOIN
  latest_products AS products
ON top_brands.brand = products.brand AND
   top_brands.category_id = product_category_id AND
   top_brands.country_code = products.approved_country;

Dalam kueri ini, ganti kode berikut:

  • DATASET: nama set data Anda
  • MERCHANT_ID: ID akun penjual
  • DATE: tanggal dalam format YYYY-MM-DD

Langkah berikutnya