dataengref migrate

Home / Oracle

Oracle to BigQuery: function mapping

13 of 15 common Oracle functions need a change in BigQuery. Mapping table with BigQuery syntax and behavior differences.

Other targets: Oracle to Snowflake · Oracle to Databricks

Needs a rewrite (11)

No BigQuery function with the same behavior; use the construct shown.

OracleBigQueryNotes
ADD_MONTHSRewrite DATE_ADD(date, INTERVAL n MONTH)Clamps to the end of the month only when the day does not exist.
Oracle ADD_MONTHS(DATE '2022-02-28', 1) returns 2022-03-31 because Feb 28 is the last day of February. Databricks and BigQuery return 2022-03-28. Month-end schedules (billing, accruals) are where this shows up.
CONNECT BYRewrite WITH RECURSIVE cte AS (anchor UNION ALL recursive_step)LEVEL and the path are computed as columns of the CTE.
LEVEL, SYS_CONNECT_BY_PATH and ORDER SIBLINGS BY have no direct form; carry a level counter and a path string in the CTE and order by the path.
DECODERewrite CASE expr WHEN search1 THEN result1 ... ELSE default ENDA simple CASE never matches NULL; add WHEN expr IS NULL THEN ... first.
DECODE(status, NULL, 'none', ...) becomes CASE WHEN status IS NULL THEN 'none' ... END. Translating it to CASE status WHEN NULL silently never matches.
DUALRewrite SELECT exprA SELECT without FROM returns one row.
Sequences read with seq.NEXTVAL FROM DUAL need a different mechanism in each target (Snowflake sequences, identity columns in Databricks, GENERATE_UUID or ROW_NUMBER in BigQuery).
MONTHS_BETWEENRewrite DATE_DIFF(date1, date2, MONTH)Counts month boundaries and returns an integer, not a fraction.
Age or tenure calculations such as FLOOR(MONTHS_BETWEEN(SYSDATE, hire_date) / 12) need a different formula; DATE_DIFF(CURRENT_DATE(), hire_date, YEAR) counts year boundaries, not completed years.
NVL2Rewrite IF(expr1 IS NOT NULL, expr2, expr3)No NVL2 function.
Oracle treats '' as NULL, so NVL2(col, 'set', 'empty') returns 'empty' for empty strings there. Add NULLIF(col, '') in the targets to keep that result.
ROWNUMRewrite LIMIT n / ROW_NUMBER() OVER (ORDER BY ...)QUALIFY is supported as well.
Oracle assigns ROWNUM before ORDER BY, so WHERE ROWNUM <= 10 ... ORDER BY x returns 10 arbitrary rows sorted afterwards. Decide whether the old query meant that or "top 10 by x" before translating it to LIMIT.
SYSDATERewrite CURRENT_DATETIME([time_zone])DATETIME in UTC unless a time zone is passed. Use CURRENT_DATE() for the date only.
Oracle SYSDATE returns the operating system time of the database server. If that server ran in a local time zone, expressions such as TRUNC(SYSDATE) mean "today in local time" and will shift by hours in a UTC warehouse.
Oracle date arithmetic such as SYSDATE - 1 (one day earlier) does not carry over to Databricks or BigQuery; use dateadd or DATETIME_SUB with an explicit unit.
TO_CHARRewrite FORMAT_DATE('%Y-%m-%d', date) / FORMAT_DATETIME('%Y-%m-%d %H:%M:%S', dt)Use the FORMAT_* function that matches the input type.
Oracle fill mode (FM) and NLS parameters for month names have no exact equivalent; check any format that uses FM, MONTH or DAY with known dates.
TO_CHAR on numbers with format models such as '999,999.00' also differs per target; test it separately from date formats.
TO_DATERewrite PARSE_DATE('%Y-%m-%d', string)Use PARSE_DATETIME to keep the time. SAFE.PARSE_DATE returns NULL on bad input.
TO_DATE('2025-03-01 14:30', 'YYYY-MM-DD HH24:MI') keeps 14:30 in Oracle. The targets drop the time when parsing to DATE, so parse to a timestamp type when the time matters.
TRUNC (date)Rewrite DATE_TRUNC(date_expression, MONTH)Use DATETIME_TRUNC or TIMESTAMP_TRUNC for other types.
TRUNC(d) with no unit means 'DD' in Oracle. In the targets, write CAST(d AS DATE) or pass 'DAY'.
Oracle format models such as 'IW' (ISO week) and 'Q' map to the target's WEEK or ISOWEEK and QUARTER parts; check week starts.

Different name (2)

Same behavior under another name; rename the call and check the notes.

OracleBigQueryNotes
LISTAGGDifferent name STRING_AGG([DISTINCT] expr [, delimiter] [ORDER BY ...])ORDER BY goes inside the parentheses. Default delimiter is a comma.
ON OVERFLOW TRUNCATE and ON OVERFLOW ERROR are Oracle only; remove the clause and check the target size limit instead.
WITHIN GROUP is not accepted; move the ORDER BY inside STRING_AGG(...).
NVLDifferent name IFNULL(expr, null_result)COALESCE also works.
Oracle stores '' as NULL, so NVL(col, 'n/a') also replaces empty strings there. In the targets an empty string is not NULL; use NVL(NULLIF(col, ''), 'n/a') to keep the Oracle result.
Oracle NVL converts expr2 to the type of expr1. The targets use a common type of both arguments, which can change numeric precision or string length in the result.

Works as written (2)

The same call runs, but check the notes for behavior differences.

OracleBigQueryNotes
INSTRSame name INSTR(value, subvalue [, position [, occurrence]])Same arguments as Oracle, including a negative position that searches from the end.
REGEXP_SUBSTRSame name REGEXP_SUBSTR(value, regexp [, position [, occurrence]])Synonym of REGEXP_EXTRACT; with one capture group it returns the group.
If the pattern has one capture group, BigQuery returns the group rather than the whole match, which differs from Oracle without the subexpr argument.

Paste a query into the SQL checker to list the functions it uses that need a change.