Scalar functions
このコンテンツはまだ日本語訳がありません。
Scalar expressions calculate one value for each input row. The functions below are recognized by the workbench. A connected source must support the particular signature too; check compatibility before using source-specific expressions.
All examples query lake.uploads.orders or lake.uploads.imported_orders. Replace these connector.dataset.table names with your catalog entries.
Text cleanup
Section titled “Text cleanup”LOWER(text)andUPPER(text)standardize case.TRIM(text),LTRIM(text), andRTRIM(text)remove surrounding, leading, or trailing whitespace.LENGTH(text)andCHAR_LENGTH(text)measure text length according to the executing source.SUBSTR(text, start, length)andSUBSTRINGselect a portion of text.REPLACE(text, search, replacement)substitutes matching text.CONCATjoins values;CONCAT_WStakes a separator first. Check null handling on your source.
SELECT order_id, UPPER(TRIM(country)) AS country_code, LOWER(status) AS normalized_status, CONCAT(country, ':', status) AS segmentFROM lake.uploads.ordersLIMIT 100;Keep original identifiers when normalizing display text. Changing case or stripping spaces can merge distinct business keys.
Numeric calculations
Section titled “Numeric calculations”ABS(value): magnitude without its sign.ROUND(value, places): round to a requested scale.CEIL(value)/CEILING(value): round toward positive infinity.FLOOR(value): round toward negative infinity.MOD(value, divisor): remainder.POWER(value, exponent): exponentiation.SQRT(value): square root; inspect negative inputs before applying it.
SELECT order_id, revenue, ROUND(revenue, 2) AS rounded_revenue, ABS(revenue) AS absolute_revenue, FLOOR(revenue / 100.0) AS hundred_unit_bandFROM lake.uploads.ordersLIMIT 100;Rounding does not change currency. Use decimal inputs where exact financial arithmetic is required and verify the transferred types in results and limits.
Nulls and bounds
Section titled “Nulls and bounds”COALESCE(a, b, ...) chooses the first available non-null value. NULLIF(a, b) returns null when its arguments are equal. GREATEST and LEAST compare values within a row; their treatment of nulls depends on the execution source.
SELECT order_id, COALESCE(country, 'Unknown') AS reporting_country, NULLIF(TRIM(status), '') AS nonblank_statusFROM lake.uploads.ordersLIMIT 100;Null and empty text are different. BLANK_TO_NULL and DEFAULT_IF_BLANK provide FastBI’s explicit blank-handling behavior.
Calendar periods
Section titled “Calendar periods”DATE_TRUNC(part, value) creates a calendar bucket. EXTRACT and DATE_PART retrieve a component. MAKE_DATE(year, month, day) constructs a date from components. Use a reporting-timezone field when the source timestamps need timezone normalization.
SELECT DATE_TRUNC('month', order_date) AS month_start, SUM(revenue) AS revenueFROM lake.uploads.ordersGROUP BY DATE_TRUNC('month', order_date)ORDER BY month_startLIMIT 100;You can also use CURRENT_DATE, CURRENT_TIMESTAMP, and NOW. Their values and timezone follow the executing source. For reproducible reports, use explicit reporting boundaries.
Conversion and formatting
Section titled “Conversion and formatting”CAST(value AS type) requests a type conversion and can fail for invalid input. TO_DATE, TO_TIMESTAMP, and TO_CHAR are recognized, but format patterns and signatures depend on the source. Do not assume one connector’s formatting tokens work everywhere.
For imperfect imports, use FastBI’s SAFE_NUMBER and SAFE_DATE functions. Invalid conversions become null, so measure conversion failures before calculating totals.
SELECT order_id, SAFE_NUMBER(revenue_text) AS revenue, SAFE_DATE(order_date_text) AS order_dateFROM lake.uploads.imported_ordersLIMIT 100;Safe ratios
Section titled “Safe ratios”Use SAFE_DIVIDE(numerator, denominator) for a ratio and PERCENT(numerator, denominator) for a percentage. Review their null and zero behavior in the function reference.
SELECT SAFE_DIVIDE(SUM(revenue), COUNT(DISTINCT customer_id)) AS revenue_per_customerFROM lake.uploads.orders;Additional functions
Section titled “Additional functions”The [workbench supported list](/sql/workbench-dialect/#built-in-function-supported list) is the boundary for submitted queries. JSON extraction, regular-expression functions, and provider-specific extensions are not automatically available. Prepare a source view exposing the required fields when an expression is outside this boundary.