Noos
PT EN
RAN-DBDEA-00219
Ranvier · DBDEA

Exam DBDEA Topics: transformation Difficulty: medium

A bronze table lands the amount column as STRING, with valid decimals like '125.50' and occasional junk like 'N/A'. The silver job must produce a DECIMAL(10,2) column, and every source row must survive: failed conversions should become NULL so the row can be routed to quarantine. Yesterday's run crashed with a CAST_INVALID_INPUT error on the first 'N/A' value. Which function meets the requirement?

Options (Reading Mode) Click to filter discussion →
  1. A. try_cast(amount AS DECIMAL(10,2)) — it returns NULL for values it cannot convert, preserving the row for quarantine routing
  2. B. cast(amount AS DECIMAL(10,2)) — Spark substitutes a default 0 whenever the string is not a valid decimal number
  3. C. rlike() pre-validation — a regex can confirm the format but cannot produce the typed DECIMAL column the silver contract requires
  4. D. No change is needed — Spark's cast is already lenient and never raises an error when the input string is malformed
Reveal answer

Correct answer: try_cast(amount AS DECIMAL(10,2)) — it returns NULL for values it cannot convert, preserving the row for quarantine routing

Reference: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-functions

02 — The Myelin Layer · Canonical Discussion

Where the exam tries to trick you — and how those who passed solved it.

0 Passed

contributed to this question

Answer Distractor Matrix Click an option to filter or open its dissection.
✦ Consolidated Synthesis (Wiki) rev. #1 (baseline) · CC BY-SA 4.0
Start synthesis for this question →

No community synthesis consolidated for this question yet. Below is the verifiable official starting point — if you passed the exam, open the option dissection.

Official Answer (A): try_cast(amount AS DECIMAL(10,2)) — it returns NULL for values it cannot convert, preserving the row for quarantine routing

Ranvier · DBDEA

Contribute to this Question

Your contribution builds your Orbital Sheath

Peer contributions

No public contribution yet. Be the first who passed to explain why the distractors trick candidates — your contribution builds your Orbital Sheath.