# How to verify order counts after a Databricks migration

> When old and new order reports disagree after a Databricks migration, compare the orders each one counted before finance signs off.

Published: 2026-11-19
Author: Ivan Vydrin
Tags: Databricks, Knowledge Share
Canonical: https://www.techfabric.com/blog/how-to-verify-order-counts-after-a-databricks-migration

---

We ran both refund rules on the same three orders in Databricks SQL. Changing `<` to `<=` dropped the count from two to one. O106 was the difference. Its refund landed at 15:00 UTC, the Monday cutoff in [our Genie One walkthrough](https://www.techfabric.com/blog/which-number-should-finance-use-when-databricks-reports-disagree).

I'd bring that row to a migration review. Before switching reports, I'd run the source and converted queries on the same data and give finance the list of orders each version kept. Two totals can match even if the new query drops one order and adds another. If the lists agree but the live reports differ, I'd check which refund batch each one read.

![Genie Search, Ontology, Migrate, and ZeroOps matched to the reporting question and evidence each helps investigate.](/blog-media/how-to-verify-order-counts-after-a-databricks-migration/genie-reporting-evidence.png)

## Find the cutoff decision with Genie Search

I'd ask Genie One to find the ticket or document where finance agreed when to stop counting refunds for the Monday report. An account admin sets up the [Genie Search](https://docs.databricks.com/aws/en/genie-one/search) connections to sources such as Jira and Google Drive, so Genie One can find and cite those records in chat. Results follow the permissions you already have in those sources.

I'd check who approved the cited record, when it took effect, and how it treats refunds at the cutoff itself. A ticket for a Friday close could be accurate and still give you the wrong rule for Monday. If the latest record leaves that boundary open, ask finance to settle it before anyone edits the SQL.

## Record the approved rule in Genie Ontology

Databricks documents Pages as a way to define business concepts and key terms as an authoritative source in Genie Ontology. I'd record finance's approved Monday cutoff there, with the timestamp field and how to treat refunds at that exact moment.

Databricks says [Genie Ontology](https://docs.databricks.com/aws/en/genie/genie-ontology/) makes that definition available to Genie One and Genie Code, subject to access permissions. If Genie has picked up a different cutoff from an old query, the definition the team recorded takes precedence. If the team already calculates the count in a metric view, I'd check that the view also follows the decision in the Page.

## Compare order IDs after conversion with Genie Migrate

[Genie Migrate](https://docs.databricks.com/aws/en/migration/genie-migrate/convert) can convert supported legacy SQL to Databricks SQL. I'd run the source query where it currently runs and the converted query in Databricks, using equivalent test data and the same cutoff. Compare the retained order IDs first. One missing order and one extra can leave the total unchanged.

We took the Monday refund at the cutoff and added a test row one second on either side. Then we ran both rules in Databricks SQL.

Both rules kept the order refunded after the cutoff. The strict rule also kept O106, which is why the count went from two to one when we switched to the inclusive rule.

![Databricks SQL results showing that only O106 changes when the refund cutoff becomes inclusive.](/blog-media/why-did-the-order-count-change-after-a-databricks-migration/databricks-cutoff-results.png)

```sql
WITH test_cases AS (
  SELECT * FROM VALUES
    (1, 'Before cutoff', '2026-11-02T14:59:59Z'),
    (2, 'At cutoff (O106)', '2026-11-02T15:00:00Z'),
    (3, 'After cutoff', '2026-11-02T15:00:01Z')
  AS cases(sort_order, test_case, refund_utc)
), inputs AS (
  SELECT *, CAST(refund_utc AS TIMESTAMP) AS refund_time,
    CAST('2026-11-02T15:00:00Z' AS TIMESTAMP) AS cutoff
  FROM test_cases
)
SELECT test_case, refund_utc,
  IF(refund_time < cutoff, 'Excluded', 'Kept') AS strict_lt,
  IF(refund_time <= cutoff, 'Excluded', 'Kept') AS inclusive_lte
FROM inputs
ORDER BY sort_order
```

I'd add all three cases to the migration check and compare the retained IDs in both directions. If an ID appears on just one side, I'd bring its refund timestamp and both SQL comparisons to whoever owns the reporting rule so they can decide which output follows the agreed cutoff.

## Check the refund refresh with Genie ZeroOps

If the two queries agree on the same data but the reports still disagree, I'd check which refund batch each report read. Start with the last successful upstream job, then check the output for the batch or refund events the Monday report expected. A successful run can still leave the report reading older data.

[Genie ZeroOps](https://docs.databricks.com/aws/en/zeroops/) is a workspace beta an admin enables. It monitors selected jobs, pipelines, and tables and can surface a failed refresh with a proposed fix. Databricks says table data-quality detection requires separately billed monitoring. I'd open the run and verify that the expected output landed before using a ZeroOps finding to explain the change in a finance report.

```mermaid
%% caption: The comparison uses the same data and cutoff before branching to SQL or freshness.
flowchart TD
  A["Order counts differ"] --> B["Find the approved cutoff"]
  B --> C["Confirm the cutoff rule"]
  C --> D["Compare IDs on the same inputs"]
  D -->|IDs differ| E["Check the SQL"]
  D -->|IDs match| F["Check the refund batch"]
```

Before switching reports, I'd ask finance to approve the cutoff and how to treat the three test cases. I'd put the actual old and new report outputs beside that decision, with the order IDs behind the totals and the refund batch each one read.

## Frequently asked questions

### What should I compare if a report has more than one row per order?

I'd check for duplicates. If the report shows an order once per region, I'd compare the order ID and region together, since a repeated pair can inflate the total even when the list of unique IDs stays the same.

### How do I check that both warehouses use the same cutoff?

I'd give both queries the same timestamp with its time zone spelled out. If the source stores local time, I'd check which zone the business uses for that report. A time like 15:00 can refer to different moments in the two systems.

### What if an order has no refund timestamp?

I'd include a paid order with no refund, along with the ones refunded near the cutoff. If that order belongs in the report, it should appear in both lists of retained IDs.
