Lý Thành
08/15/2026, 7:23 AMRocky
08/15/2026, 7:23 AMLý Thành
08/15/2026, 7:23 AMRocky
08/15/2026, 7:23 AMstarrocks::BinaryColumnBase<unsigned int>::_build_slices(), which is triggered by the replace string function.
Analysis of the Stack Trace
The trace reveals a specific path in the vectorized execution engine:
1. Operator: ProjectOperator (performing an expression evaluation).
2. Expression Tree: VectorizedArithmeticExpr → VectorizedCoalesceExpr → VectorizedCastExpr → VectorizedNullIfExpr → replace.
3. Point of Failure: The replace function uses a ColumnViewer to access string data. The ColumnViewer calls _build_slices() to prepare the string offsets and data for processing. The crash happens here, likely because it is attempting to access a memory address that is null or has already been freed.
Potential Causes
* Nullability Inconsistency: The expression involves COALESCE, CAST, and NULLIF. There are known issues in some StarRocks versions where the nullability of a column is incorrectly handled after a CAST or COALESCE operation, causing downstream functions (like replace) to receive a column that doesn't match its expected internal structure.
* Constant vs. Vectorized Column Mismatch: If one of the arguments to replace (the string, the pattern, or the replacement) is a constant that was converted into a specific column type incorrectly, the ColumnViewer might fail when trying to build slices for it.
* Memory Corruption/Use-after-free: The crash in _build_slices can occur if the underlying data buffer or offset buffer of a BinaryColumn has been released prematurely.
Recommended Troubleshooting Steps
1. Identify the Query: The query_id is 01a0012d-75f7-7c9e-a51f-010a458607d5. Check your FE (Frontend) logs (fe.audit.log or fe.log) for this ID to find the exact SQL being executed.
2. Simplify the Expression: Once you have the SQL, try to isolate the part of the SELECT or WHERE clause causing the crash. It likely looks something like:
sql
REPLACE(COALESCE(CAST(NULLIF(col1, col2) AS VARCHAR), 'default'), 'search', 'replace')
3. Check for Known Bug: Version 4.0.12 (referenced in your log as a 2026 release) suggests you may be running a very recent or potentially unreleased/development build if this is a simulation. However, in StarRocks 3.x and 4.x, similar crashes have been linked to Issue #65454 or #65429, where incorrect nullability settings after expression merging caused BE crashes.
4. Workaround: Try rewriting the expression to use CASE WHEN instead of a nested NULLIF/COALESCE/CAST chain to see if the crash persists.
_ _Example*: Replace NULLIF(a, b) with CASE WHEN a = b THEN NULL ELSE a END.
Next Steps
If you can provide the SQL query and the schema (DDL) of the tables involved, I can help determine if there is a specific data pattern or expression nesting that is triggering this bug. You should also consider reporting this to the StarRocks community via GitHub or Slack, attaching the full be.out log.
References
• sql-reference/sql-functions/condition-functions/coalesce.md
• sql-reference/sql-functions/string-functions/replace.md
• sql-reference/sql-functions/condition-functions/nullif.md
• sql-reference/sql-functions/condition-functions/ifnull.md
• knowledge/usage/best-practice.mdRocky
08/15/2026, 7:23 AMLý Thành
08/17/2026, 4:17 AMRocky
08/17/2026, 4:18 AMLOSREP.APPLICATION table to StarRocks, you should use the Primary Key model since the original table defines a primary key (ID).
Key Mapping Considerations:
1. Data Types:
* NUMBER(p, 0) maps to BIGINT (up to 19 digits) or DECIMAL(p, 0).
* NUMBER(p, s) maps to DECIMAL(p, s).
* VARCHAR2(n) maps to VARCHAR(n). Note: StarRocks VARCHAR limit is 65,533 bytes.
* DATE in Oracle includes time, so it maps to DATETIME in StarRocks.
* CLOB is mapped to VARCHAR(65533). If the data is specifically JSON, you could use the JSON type.
2. Constraints:
* StarRocks Primary Key tables enforce uniqueness on the primary key.
* StarRocks does not support additional UNIQUE constraints or CHECK constraints.
3. Storage:
* The DISTRIBUTED BY HASH(ID) clause is used to spread data across the cluster.
StarRocks DDL
```sql
CREATE TABLE APPLICATION (
ID DECIMAL(20,0) NOT NULL COMMENT "Original: NUMBER(20,0)",
APP_UID VARCHAR(50),
APP_NUMBER BIGINT COMMENT "Original: NUMBER(11,0)",
APP_CODE VARCHAR(20),
BUSINESS_LINE VARCHAR(50),
BUSINESS_PROCESS VARCHAR(50),
LOAN_PURPOSE VARCHAR(50),
LOAN_PURPOSE_LBL VARCHAR(250),
LOAN_PURPOSE_OTHER VARCHAR(250),
PRODUCT_CATEGORY VARCHAR(50),
PRODUCT_CATEGORY_LBL VARCHAR(250),
SCHEME_PRODUCT VARCHAR(50),
SCHEME_PRODUCT_LBL VARCHAR(250),
LOAN_TERM VARCHAR(50),
YEAR_INTEREST DECIMAL(5,2),
MONTH_INTEREST DECIMAL(5,2),
HAS_INSURANCE VARCHAR(50),
INSURANCE_COMPANY VARCHAR(50),
INSURANCE_COMPANY_LBL VARCHAR(250),
INSURANCE_RATE DECIMAL(5,2),
INSURANCE_FEE DECIMAL(20,2),
LOAN_CONSUMER DECIMAL(20,2),
LOAN_AMOUNT DECIMAL(20,2),
CUSTOMER_NAME VARCHAR(250),
CUSTOMER_SHORT_NAME VARCHAR(250),
CUSTOMER_NICK_NAME VARCHAR(250),
CUSTOMER_CODE VARCHAR(50),
DATE_OF_BIRTH DATETIME,
GENDER VARCHAR(50),
MARITAL_STATUS VARCHAR(50),
MARITAL_STATUS_LBL VARCHAR(100),
EDUCATION VARCHAR(50),
EDUCATION_LBL VARCHAR(100),
PASSPORT_NUMBER VARCHAR(50),
ID_CARD_TYPE VARCHAR(50),
ID_CARD_NUMBER VARCHAR(50),
ID_CARD_ISSUE_DATE DATETIME,
ID_CARD_ISSUE_PLACE VARCHAR(50),
ID_CARD_ISSUE_PLACE_LBL VARCHAR(100),
ID_CARD_NUMBER_OTHER VARCHAR(50),
MOBILE_PHONE VARCHAR(50),
MOBILE_PHONE_OTHER VARCHAR(50),
EMAIL VARCHAR(100),
JOB VARCHAR(50),
JOB_LBL VARCHAR(100),
JOB_OTHER VARCHAR(250),
POA_TYPE VARCHAR(50),
POA_TYPE_LBL VARCHAR(150),
POA_NUMBER VARCHAR(50),
POA_ISSUE_DATE DATETIME,
POA_ISSUE_PLACE VARCHAR(50),
POA_ISSUE_PLACE_LBL VARCHAR(100),
HOME_PHONE VARCHAR(50),
COMPANY_ADDRESS VARCHAR(500),
WORKING_ADDRESS VARCHAR(500),
TEMPORARY_RESIDENCE_STATUS VARCHAR(50),
PERMANENT_ADDRESS VARCHAR(500),
TEMPORARY_ADDRESS VARCHAR(500),
DISBURSEMENT_CHANNEL VARCHAR(50),
AGENCY_PAYMENT VARCHAR(50),
ACCOUNT_NUMBER VARCHAR(50),
ACCOUNT_NAME VARCHAR(100),
BANK_NAME VARCHAR(50),
BRANCH_NAME VARCHAR(250),
SALE_DEPARTMENT_PATH VARCHAR(250),
SALE_CODE VARCHAR(50),
SALE_NAME VARCHAR(250),
SALE_MOBILE VARCHAR(50),
APPLICATION_DATE DATETIME,
APPROVAL_DATE DATETIME,
CONTRACT_NUMBER VARCHAR(50),
SIGN_CONTRACT_DATE DATETIME,
LOAN_DEPOSIT_NUMBER VARCHAR(50),
MONTHLY_PAYMENT DECIMAL(20,2),
FIRST_PAYMENT_DATE DATETIME,
DISBURSEMENT_DATE DATETIME,
DISBURSEMENT_STATUS VARCHAR(50),
CREATED_DATE DATETIME,
CREATED_BY VARCHAR(50),
LAST_UPDATED_DATE DATETIME,
LAST_UPDATED_BY VARCHAR(50),
LMS_CIF VARCHAR(50),
BANK_NAME_LBL VARCHAR(250),
DISBURSEMENT_CHANNEL_LBL VARCHAR(250),
APPLICATION_SERI_NUMBER VARCHAR(50),
DISBURSEMENT_FEE DECIMAL(20,2),
PARTNER_ID VARCHAR(50),
DATA_SOURCE VARCHAR(50),
SALE_HR_CODE VARCHAR(50),
SALE_LEAD_CODE VARCHAR(50),
SALE_LEAD_NAME VARCHAR(250),
SALE_LEAD_MOBILE VARCHAR(50),Rocky
08/17/2026, 4:18 AMreplace) involving complex expressions. When using this table:
* CLOB Data: If PRODUCT_DATA contains JSON, consider using the JSON type for better performance and easier querying.
* Expression Safety: If you use this table in queries with nested REPLACE(COALESCE(...)) functions, ensure the input types are correctly cast to avoid the BE crash seen in your previous log.
References
• table_design/table_types/Primary_key_table.md
• sql-reference/sql-statements/data-types/DECIMAL.md
• sql-reference/sql-statements/data-types/DATETIME.md
• sql-reference/sql-statements/data-types/VARCHAR.md
• sql-reference/sql-statements/data-definition-language/CREATE_TABLE.md
• table_design/Data_types.md
• sql-reference/sql-statements/data-types/JSON.md
• table_design/Sort_key.mdLý Thành
08/17/2026, 8:38 AMRocky
08/17/2026, 8:38 AMsql
CREATE TABLE sales_records (
record_id INT,
seller_id INT,
store_id INT,
sale_date DATE,
sale_amt DECIMAL(10, 2)
)
DUPLICATE KEY(record_id, seller_id)
DISTRIBUTED BY HASH(record_id);
2. Tạo Materialized View đồng bộ (Sync MV)
Chúng ta muốn tính tổng doanh số theo từng cửa hàng (store_id). Sync MV sẽ tự động tính toán và lưu trữ kết quả này.
sql
CREATE MATERIALIZED VIEW mv_store_sales AS
SELECT
store_id,
SUM(sale_amt) AS total_sales
FROM sales_records
GROUP BY store_id;
3. Cách hoạt động và đặc điểm
* Tự động cập nhật: Khi bạn dùng INSERT INTO hoặc Stream Load để nạp dữ liệu vào bảng sales_records, StarRocks sẽ tự động tính toán phần chênh lệch và cập nhật vào mv_store_sales trong cùng một transaction.
* Tự động Query Rewrite: Bạn không cần phải gọi tên MV trong câu lệnh SELECT. Optimizer của StarRocks sẽ tự nhận diện và lấy dữ liệu từ MV nếu nó nhanh hơn.
Ví dụ truy vấn:
Dù bạn viết lệnh truy vấn vào bảng gốc:
sql
SELECT store_id, SUM(sale_amt) FROM sales_records GROUP BY store_id;
Nhưng thực tế StarRocks sẽ đọc từ mv_store_sales để trả kết quả ngay lập tức mà không cần quét toàn bộ bảng gốc.
4. Một số lưu ý quan trọng (Hạn chế của Sync MV)
1. Chỉ hỗ trợ một bảng: Không thể JOIN nhiều bảng trong Sync MV (nếu muốn JOIN bạn phải dùng Async MV).
2. Hàm gộp hạn chế: Chỉ hỗ trợ các hàm cơ bản như SUM, MIN, MAX, COUNT, BITMAP_UNION, HLL_UNION.
3. Bảng gốc: Chỉ hỗ trợ các bảng loại Duplicate Key, Primary Key hoặc Aggregate Key.
4. Hiệu năng ghi: Vì là cập nhật đồng bộ, nếu bạn tạo quá nhiều Sync MV trên một bảng, tốc độ nạp dữ liệu (Load) vào bảng đó có thể bị chậm lại một chút.
Khi nào nên dùng Sync MV thay vì Async MV?
* Dùng Sync MV khi bạn cần dữ liệu real-time tuyệt đối (vừa nạp vào là thấy ngay) và chỉ cần tính toán đơn giản trên 1 bảng.
* Dùng Async MV khi bạn cần JOIN nhiều bảng, dùng các hàm phức tạp (Window functions) hoặc khi bảng gốc có lượng dữ liệu khổng lồ mà bạn chấp nhận độ trễ (latency) vài phút để làm mới dữ liệu.
Tài liệu tham khảo
• table_design/materialized_view/Materialized_view.md
• sql-reference/sql-statements/data-definition-language/CREATE_MATERIALIZED_VIEW.md
• using_starrocks/async_mv/Materialized_view.md
• table_design/materialized_view/explore_materialized_view.mdLý Thành
08/19/2026, 7:27 AMRocky
08/19/2026, 7:27 AMSELECT permissions on all databases and tables to a specific user or role in StarRocks, you use the GRANT statement with the ALL DATABASES scope.
1. Grant to a User
Replace 'username'@'host' with your actual user identity (e.g., 'john'@'%').
sql
GRANT SELECT ON ALL TABLES IN ALL DATABASES TO USER 'username'@'host';
2. Grant to a Role
It is often better practice to grant permissions to a role and then assign the user to that role.
sql
-- Create the role (if it doesn't exist)
CREATE ROLE read_only_all;
-- Grant select on all tables/views in all databases
GRANT SELECT ON ALL TABLES IN ALL DATABASES TO ROLE read_only_all;
-- Assign the role to a user
GRANT 'read_only_all' TO USER 'username'@'host';
Important Considerations:
* Views: The SELECT privilege on ALL TABLES typically covers both physical tables and views.
* Catalogs: If you are using StarRocks 3.0+ with External Catalogs (like Hive or Iceberg), you might need to specify the catalog or use the global syntax if the user needs access beyond the default_catalog.
* To grant on all tables in a specific external catalog:
GRANT SELECT ON ALL TABLES IN ALL DATABASES ON CATALOG <catalog_name> TO USER 'username'@'host';
* Permissions Required: You must have the user_admin role or the GRANT privilege to execute these commands.
* Verify Permissions: You can check the granted permissions using:
sql
SHOW GRANTS FOR 'username'@'host';
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/privilege_item.md
• sql-reference/sql-statements/account-management/SHOW_GRANTS.md
• administration/Manage_privileges.md
• sql-reference/sql-statements/account-management/CREATE_USER.md
• sql-reference/sql-statements/account-management/REVOKE.md
• administration/native_auth.md
• sql-reference/sql-statements/account-management/CREATE_ROLE.mdLý Thành
08/19/2026, 8:52 AMRocky
08/19/2026, 8:52 AMON ALL MATERIALIZED VIEWS IN DATABASE is used to grant privileges (like SELECT, REFRESH, or ALTER) on MVs that already exist. You cannot "create" an object on an object that doesn't exist yet.
2. Privilege Name: The specific privilege name is CREATE MATERIALIZED VIEW, not just CREATE.
The correct command:
To allow the user hungnm40 to create materialized views in the database dmapp, use:
sql
GRANT CREATE MATERIALIZED VIEW ON DATABASE dmapp TO USER 'hungnm40'@'%';
(Note: Replace '%' with the actual host if necessary, or omit USER if hungnm40 is a role).
Summary of related privileges:
* To create MVs: GRANT CREATE MATERIALIZED VIEW ON DATABASE <db> TO ...
* To manage existing MVs: GRANT REFRESH, ALTER, DROP ON ALL MATERIALIZED VIEWS IN DATABASE <db> TO ...
* To query existing MVs: GRANT SELECT ON ALL MATERIALIZED VIEWS IN DATABASE <db> TO ...
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/privilege_item.md
• using_starrocks/async_mv/Materialized_view.md
References
• sql-reference/sql-statements/account-management/GRANT.mdLý Thành
08/19/2026, 9:17 AMRocky
08/19/2026, 9:17 AMCREATED_DATE column by day in StarRocks, you have two primary options depending on whether you want the result to be a DATE type or a DATETIME type.
1. Using date() or to_date() (Recommended)
This is the simplest way. It converts the datetime into a DATE type (YYYY-MM-DD), removing the time component completely.
sql
SELECT
date(CREATED_DATE) AS daily,
count(*)
FROM your_table
GROUP BY daily;
_Note: to_date(CREATED_DATE) works identically._
2. Using date_trunc()
This function truncates the time to the start of the day (00:00:00). It is useful if you want to keep the result as a DATETIME type.
sql
SELECT
date_trunc('day', CREATED_DATE) AS daily,
count(*)
FROM your_table
GROUP BY daily;
3. Using CAST
You can also explicitly cast the column to a DATE type.
sql
SELECT
CAST(CREATED_DATE AS DATE) AS daily,
count(*)
FROM your_table
GROUP BY daily;
Summary of results:
Input | date() / CAST | date_trunc('day', ...)
2025-03-17 13:44:44 | 2025-03-17 | 2025-03-17 00:00:00
Performance Tip: If you frequently group or filter by date on a very large table, consider using Expression Partitioning with date_trunc('day', CREATED_DATE) to improve query performance via partition pruning.
References
• sql-reference/sql-functions/date-time-functions/date.md
• sql-reference/sql-functions/date-time-functions/to_date.md
• sql-reference/sql-functions/date-time-functions/date_trunc.md
• table_design/data_distribution/expression_partitioning.md
References
• sql-reference/sql-functions/date-time-functions/date.md
• sql-reference/sql-functions/date-time-functions/date_trunc.md
• sql-reference/sql-functions/date-time-functions/to_tera_date.md
• sql-reference/sql-functions/date-time-functions/str2date.md
• sql-reference/sql-functions/date-time-functions/to_date.md
• sql-reference/sql-functions/date-time-functions/timestamp.md
• sql-reference/sql-functions/date-time-functions/to_datetime.mdLý Thành
08/20/2026, 3:41 AMRocky
08/20/2026, 3:41 AMSELECT statement to transform data types.
* Using CAST: You can explicitly cast a column to a different type.
* Using Date Functions: You can convert strings or datetimes to dates.
Example:
sql
CREATE MATERIALIZED VIEW mv_daily_sales
REFRESH ASYNCHRONOUS
AS
SELECT
CAST(user_id AS VARCHAR) AS user_id_str, -- Change INT to VARCHAR
date(created_at) AS report_date, -- Change DATETIME to DATE
SUM(price) AS total_revenue
FROM sales_table
GROUP BY user_id_str, report_date;
2. Synchronous Materialized Views
In StarRocks v3.1 and later, synchronous MVs also support complex expressions and type casting in the SELECT list.
* Requirement: You must provide an alias for any column that uses an expression or a type change.
* Example:
sql
CREATE MATERIALIZED VIEW sync_mv AS
SELECT
k1,
CAST(k2 AS BIGINT) AS k2_big, -- Type change with alias
SUM(v1)
FROM base_table
GROUP BY k1, k2_big;
Key Considerations
* Query Rewrite: If you change the data type in an MV, StarRocks can still use it to rewrite queries automatically, provided the query's logic matches the MV's transformed columns.
* Partition Keys: You can even change the data type of a partition key from the base table (e.g., from STRING to DATE) to enable more efficient partitioning in the materialized view.
* Precision: Be careful when casting to types with lower precision (e.g., DOUBLE to INT), as this will truncate data in the MV.
References
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• using_starrocks/Materialized_view-single_table.md
• using_starrocks/async_mv/Materialized_view.md
References
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• using_starrocks/Materialized_view-single_table.md
• using_starrocks/async_mv/feature-support-asynchronous-materialized-views.mdLý Thành
08/20/2026, 3:44 AMRocky
08/20/2026, 3:44 AMsql
CREATE MATERIALIZED VIEW order_mv
DISTRIBUTED BY HASH(`order_id`)
REFRESH ASYNC START('2025-03-18 00:00:00') EVERY (INTERVAL 1 DAY)
AS
SELECT order_id, sum(price) as total
FROM order_list
GROUP BY order_id;
B. Manual Refresh Only
If you don't want automatic schedules, set the refresh strategy to MANUAL.
sql
CREATE MATERIALIZED VIEW manual_mv
DISTRIBUTED BY HASH(`user_id`)
REFRESH MANUAL
AS
SELECT user_id, count(*) FROM activity_log GROUP BY user_id;
C. Immediate vs. Deferred
* Default (IMMEDIATE): The MV starts building (refreshing) as soon as the CREATE statement finishes.
* Deferred: Use REFRESH DEFERRED if you want to create the definition now but wait to populate the data later.
sql
CREATE MATERIALIZED VIEW deferred_mv
REFRESH DEFERRED MANUAL
AS SELECT ...;
──────────
2. How to Refresh the MV
You can trigger a refresh manually regardless of the defined schedule.
Manual Trigger (Async Call)
This sends the task to the background. The command returns immediately, but the refresh continues in the background.
sql
REFRESH MATERIALIZED VIEW order_mv;
Manual Trigger (Sync Call)
The SQL client will wait until the refresh is actually finished before returning.
sql
REFRESH MATERIALIZED VIEW order_mv WITH SYNC MODE;
Refresh Specific Partitions
If your MV is partitioned, you can save resources by refreshing only specific ranges.
sql
REFRESH MATERIALIZED VIEW order_mv PARTITION ('2025-03-17', '2025-03-18');
──────────
3. Monitoring Refresh Status
Since these tasks run in the background, you can check their progress using the information_schema.
* Check the Task Name:
sql
SELECT * FROM information_schema.tasks WHERE TASK_NAME LIKE '%order_mv%';
* Check Success/Failure History:
sql
SELECT TASK_NAME, CREATE_TIME, FINISH_TIME, STATE, ERROR_MESSAGE
FROM information_schema.task_runs
ORDER BY CREATE_TIME DESC
LIMIT 10;
Key Rules
* Base Tables: Async MVs can be built on StarRocks internal tables, external tables (like Hive, Iceberg), or even other MVs.
* Partitioning: It is highly recommended to partition your MV if the base table is large. This allows StarRocks to perform incremental refreshes (only updating changed partitions) instead of a full rebuild.
References
• using_starrocks/async_mv/Materialized_view.md
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• using_starrocks/async_mv/troubleshooting_asynchronous_materialized_views.md
References
• using_starrocks/async_mv/troubleshooting_asynchronous_materialized_views.md
• using_starrocks/async_mv/Materialized_view.md
• using_starrocks/async_mv/materialized_view_task_run_details.mdLý Thành
08/20/2026, 3:51 AMcard_account_no, los_contract_no)
PROPERTIES (
"compression" = "LZ4",
"enable_persistent_index" = "true",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "2"
)
add properties to masterial viewRocky
08/20/2026, 3:51 AMDISTRIBUTED BY clause and a PROPERTIES block.
However, not all standard table properties are valid or necessary for Materialized Views. Below is how you should structure your SQL and which properties to keep or remove.
Recommended SQL Structure
sql
CREATE MATERIALIZED VIEW your_mv_name
REFRESH ASYNC -- Or MANUAL
DISTRIBUTED BY HASH(`card_account_no`, `los_contract_no`)
PROPERTIES (
"replication_num" = "2",
"compression" = "LZ4",
"replicated_storage" = "true" -- Use only if you are on a Shared-data (Cloud Native) cluster
)
AS
SELECT
card_account_no,
los_contract_no,
count(*) as cnt
FROM your_source_table
GROUP BY card_account_no, los_contract_no;
Analysis of your requested properties:
1. DISTRIBUTED BY HASH(...): (Supported)
This is standard and recommended to align the distribution with your query patterns. Note that it is a standalone clause, not inside the PROPERTIES block.
2. "replication_num" = "2": (Supported)
Valid for StarRocks shared-nothing clusters. Ensure you have at least 2 Backend (BE) nodes.
3. "compression" = "LZ4": (Supported/Default)
StarRocks uses LZ4 by default for all tables and MVs. You can explicitly set it, but it is usually unnecessary.
4. "replicated_storage" = "true": (Shared-data Only)
Only include this if you are using StarRocks shared-data (cloud-native) architecture. For standard shared-nothing clusters, this property is not used.
5. "enable_persistent_index" = "true": (NOT SUPPORTED)
Persistent Indexes are only for Primary Key tables. Asynchronous MVs in StarRocks are built on a Duplicate Key model (internally), so they do not support this property. Including it will likely cause an error.
6. "fast_schema_evolution" = "true": (NOT APPLICABLE)
MVs derive their schema directly from the SELECT query. If the base table schema changes, the MV is typically updated via REFRESH or ALTER MATERIALIZED VIEW ... ACTIVE. You do not set this property on the MV itself.
How to add/change properties on an EXISTING MV
If the MV already exists, use `ALTER MATERIALIZED VIEW`:
sql
ALTER MATERIALIZED VIEW your_mv_name SET ("replication_num" = "3");
References
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• sql-reference/sql-statements/materialized_view/ALTER_MATERIALIZED_VIEW.md
• using_starrocks/async_mv/Materialized_view.md
References
• using_starrocks/async_mv/use_cases/query_rewrite_with_materialized_views.mdLý Thành
08/20/2026, 4:01 AMRocky
08/20/2026, 4:01 AMinformation_schema database contains logs of every refresh attempt. You can check if a refresh is RUNNING, SUCCESS, or FAILED.
sql
-- View all recent refresh attempts
SELECT
TASK_NAME,
CREATE_TIME,
FINISH_TIME,
STATE, -- PENDING, RUNNING, FAILED, SUCCESS
PROGRESS, -- e.g., "50%"
ERROR_MESSAGE
FROM information_schema.task_runs
ORDER BY CREATE_TIME DESC
LIMIT 10;
_Note: To filter for a specific MV, find its TASK_NAME by querying SELECT _ FROM information_schema.tasks.*
2. View Real-Time Progress
If a refresh is currently running and you want to see its resource usage (CPU, Memory, Rows Scanned), use the SHOW PROC command:
sql
-- Shows all currently running queries/tasks
SHOW PROC '/current_queries';
Look for an INSERT OVERWRITE statement in the output; this is how StarRocks performs the MV refresh internally.
3. Check MV Metadata
To see the last time an MV was refreshed and whether it is currently active, use:
sql
SHOW MATERIALIZED VIEWS WHERE NAME = 'your_mv_name' \G
Key fields to look for:
* last_refresh_time: When the last successful refresh finished.
* is_active: If false, the MV might be out of sync or failed a schema update.
* last_refresh_error_message: Brief summary of the most recent error.
4. Analyze Refresh Performance (Profiles)
For deep troubleshooting (e.g., "Why is my refresh so slow?"), you can view the Query Profile:
1. Go to the StarRocks FE Web UI (usually http://<FE_IP>:8030).
2. Navigate to the Queries or Finished Queries tab.
3. Look for the INSERT OVERWRITE statement that corresponds to your MV refresh.
4. Click the Profile link to see a detailed breakdown of execution time across nodes.
5. Prometheus Monitoring
If you have Prometheus and Grafana set up, StarRocks exports specific metrics for MVs (v3.1+):
* `mv_refresh_jobs`: Total number of refresh jobs.
* `mv_refresh_total_success_jobs`: Success count.
* `mv_refresh_total_failed_jobs`: Failure count.
References
• using_starrocks/async_mv/troubleshooting_asynchronous_materialized_views.md
• using_starrocks/async_mv/Materialized_view.md
• administration/management/monitoring/metrics-materialized_view.md
References
• using_starrocks/async_mv/troubleshooting_asynchronous_materialized_views.md
• using_starrocks/async_mv/Materialized_view.md
• administration/management/monitoring/metrics-materialized_view.md
_view)
References
• using_starrocks/async_mv/troubleshooting_asynchronous_materialized_views.md
• using_starrocks/async_mv/Materialized_view.md
• administration/management/monitoring/metrics-materialized_view.mdLý Thành
08/20/2026, 7:18 AMRocky
08/20/2026, 7:19 AMsql
CREATE TABLE DWH.etl_dwh_log (
sys_run_date DATE NOT NULL,
seq_no BIGINT NOT NULL,
function_code VARCHAR(100) NOT NULL,
package_name VARCHAR(100),
procedure_name VARCHAR(100),
table_name VARCHAR(100),
deal_no VARCHAR(50),
sub_deal_no VARCHAR(50),
total_record BIGINT,
status VARCHAR(3),
run_time DATETIME NOT NULL,
error_desc VARCHAR(4000)
)
DUPLICATE KEY(sys_run_date, seq_no, function_code)
PARTITION BY RANGE(sys_run_date) (
START ("2024-01-01") END ("2025-01-01") EVERY (INTERVAL 1 MONTH)
)
DISTRIBUTED BY HASH(seq_no) BUCKETS 8
PROPERTIES (
"replication_num" = "3",
"compression" = "LZ4"
);
Key Mapping & Design Notes
1. Data Types:
* NUMBER: Converted to BIGINT. If your numbers have decimals, use DECIMAL(precision, scale).
* VARCHAR2: Converted to VARCHAR. StarRocks VARCHAR supports up to 1,048,576 bytes.
* DATE (Oracle): In Oracle, DATE includes time. I mapped RUN_TIME to DATETIME to preserve the hours/minutes/seconds, and SYS_RUN_DATE to DATE (YYYY-MM-DD).
2. DUPLICATE KEY:
* This replaces the traditional index for performance. Put the columns you filter by most often (like sys_run_date) first in this list. This defines the sort order on disk.
3. Constraints:
* StarRocks does not support CHECK constraints. Use NOT NULL in the column definition instead.
4. Partitioning:
* For log tables, it is highly recommended to use PARTITION BY RANGE on the date column. This makes it much faster to delete old data (dropping a partition) and improves query speed.
5. Distribution:
* `DISTRIBUTED BY HASH(seq_no)`: This spreads data across the cluster nodes. Use a high-cardinality column like a sequence number or ID.
6. Index:
* The ETL_DWH_LOG_IDX1 on SYS_RUN_DATE from your original DDL is handled automatically by putting sys_run_date at the beginning of the DUPLICATE KEY clause.
References
• table_design/table_types/duplicate_key_table.md
• sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.md
• table_design/data_types.mdLý Thành
08/20/2026, 7:43 AMRocky
08/20/2026, 7:43 AM'19Aug26' from today's date, you need to subtract one day and then use the date_format function with specific identifiers.
The SQL Query
sql
SELECT date_format(date_sub(current_date(), INTERVAL 1 DAY), '%d%b%y');
Breakdown of functions:
1. date_sub(current_date(), INTERVAL 1 DAY): Subtracts 1 day from the current date (to get the "19th" when today is the "20th").
2. date_format(..., '%d%b%y'):
* %d: Day of the month as a numeric value (01 to 31).
* %b: Abbreviated month name (e.g., Jan, Feb, Aug).
* %y: Year as a two-digit numeric value (e.g., 26).
Alternative: If you just want to format the current date
If your example "19Aug26" was just a format preference and you want to apply it to today's date directly:
sql
SELECT date_format(current_date(), '%d%b%y');
-- Output: '20Aug26'
References
• sql-reference/sql-functions/date-time-functions/date_format.md
• sql-reference/sql-functions/date-time-functions/date_sub.mdLý Thành
08/20/2026, 7:52 AMRocky
08/20/2026, 7:52 AM(SELECT date_format(...)) as a Join operation rather than a simple filter.
In StarRocks, JDBC external tables only push down predicates that are literal constants (like '19Aug26') or expressions that can be folded into constants at the planning stage. When you use a join or a subquery to provide the value, the optimizer usually plans to fetch the data from both sides and perform the join locally in StarRocks.
How to Fix It
To trigger Predicate Pushdown (sending the WHERE clause to Oracle), you should move the date calculation directly into the WHERE clause of your main query.
Recommended SQL:
sql
SELECT *, CURRENT_DATE()
FROM dwh_link.etl_dwh_log_link
WHERE sys_run_date = date_format(date_sub(current_date(), INTERVAL 1 DAY), '%d%b%y');
Why this works:
1. Constant Folding: StarRocks evaluates date_format(date_sub(current_date(), INTERVAL 1 DAY), '%d%b%y') at the beginning of query execution because it is a "deterministic" expression.
2. Predicate Pushdown: Once the expression is folded into a string (e.g., '19Aug26'), the optimizer sees a simple comparison: sys_run_date = '19Aug26'.
3. Remote Execution: StarRocks then generates the SQL SELECT ... FROM DWH.etl_dwh_log WHERE sys_run_date = '19Aug26' and sends it to Oracle.
Troubleshooting Tips
* Use EXPLAIN: Run EXPLAIN <your_sql> and look for the JDBC SCAN node. Check the PREDICATES section. If you see the filter there, it is being pushed to Oracle. If you see it in a JOIN or FILTER node above the scan, it is being processed locally in StarRocks.
* JDBC Catalog (Recommended): The ENGINE=JDBC external table is deprecated. If you are on StarRocks v3.2.9+ or v3.3.1+, it is highly recommended to use a JDBC Catalog for Oracle. Catalogs have a more advanced optimizer that handles predicate pushdown much more efficiently than the old external tables.
* Data Type Warning: Your StarRocks table defines sys_run_date as datetime, but you are comparing it to a string '19Aug26'. While Oracle might handle this via implicit conversion, it is safer to compare datetime to a standard ISO format (e.g., '2026-08-19') to avoid NLS setting issues in Oracle.
References
• data_source/External_table.md
• data_source/catalog/jdbc_catalog.md
• sql-reference/sql-functions/date-time-functions/date_format.md
References
• data_source/External_table.md
• using_starrocks/accelerate-cardinality-preserving-joins.md
• using_starrocks/async_mv/use_cases/query_rewrite_with_materialized_views.mdLý Thành
08/20/2026, 8:20 AMRocky
08/20/2026, 8:20 AMreplace string function during query execution.
Analysis of the Crash
The crash is triggered at starrocks::BinaryColumnBase<unsigned int>::_build_slices(). Based on the stack trace, the sequence leading to the crash is:
1. A ProjectOperator is evaluating a complex expression.
2. The expression involves a combination of replace(), nullif(), cast(), and coalesce().
3. The replace function calls ColumnViewer to access string data, which then attempts to build "slices" (pointers to the string data).
4. The crash happens because the underlying column data is in an unexpected state (likely due to how nulls or constants are handled when nested inside COALESCE or CAST in the vectorized engine).
Known Issue
This matches a recently reported issue in the StarRocks community:
* GitHub Issue: #77858 - BE 4.0.12 crash
* Status: Open / Under Investigation.
Suggested Workarounds
Until a formal patch is released in a newer 4.0.x maintenance version, you can try the following to mitigate the crash:
1. Simplify/Rewrite the Expression:
If your query uses a pattern like COALESCE(CAST(REPLACE(...) AS ...), ...) or NULLIF(REPLACE(...), ...), try to break it down. Sometimes changing the order of functions or using a CASE WHEN statement instead of COALESCE/NULLIF can bypass the specific vectorized code path that causes the crash.
_ _Example:* Replace NULLIF(REPLACE(col, 'a', 'b'), '') with CASE WHEN REPLACE(col, 'a', 'b') = '' THEN NULL ELSE REPLACE(col, 'a', 'b') END.
2. Disable Specific Optimizations (If applicable):
If the crash only happens during a specific join or complex projection, you can try to identify if a specific session variable affects it. However, since this is a core string function crash, a rewrite is usually more effective.
3. Blacklist the Query:
If this is a recurring query that brings down your BE nodes, you can temporarily add it to the SQL blacklist to prevent it from running and crashing the cluster:
sql
ADD SQLBLACKLIST "regex_matching_your_query";
Recommendation
I recommend tracking GitHub issue #77858 for updates. Once a fix is merged, you will likely need to upgrade to the next patch release (e.g., v4.0.13 or v4.0.14) to resolve the issue permanently.
If you can provide the specific SQL query causing the crash, I can help you find a safe way to rewrite it.Lý Thành
08/25/2026, 7:09 AMRocky
08/25/2026, 7:09 AMtrim('Abc 123 43') is:
'Abc 123 43'
Why?
The trim() function in StarRocks only removes leading and trailing spaces. It does not remove spaces located in the middle of the string.
If you want to remove all spaces (including those in the middle), you should use the replace() function:
sql
SELECT replace('Abc 123 43', ' ', '');
-- Result: 'Abc12343'
References
• sql-reference/sql-functions/string-functions/trim.md
• sql-reference/sql-functions/string-functions/replace.mdLý Thành
08/25/2026, 7:13 AMRocky
08/25/2026, 7:13 AMUPDATE privilege on all tables within a specific database is:
sql
GRANT UPDATE ON ALL TABLES IN DATABASE lps TO USER 'hungnm40'@'%';
Key Changes:
1. ON keyword: StarRocks requires the ON keyword before the resource.
2. ALL TABLES IN DATABASE: This is the specific clause required to target everything inside the lps database.
3. Space after USER: Ensure there is a space between the keyword USER and the identifier 'hungnm40'@'%'.
Important Note:
You must ensure you have set the correct catalog (usually default_catalog) before running this command, or specify it if you are using multiple catalogs:
sql
SET CATALOG default_catalog;
GRANT UPDATE ON ALL TABLES IN DATABASE lps TO USER 'hungnm40'@'%';
References
• sql-reference/sql-statements/account-management/GRANT.md
References
• sql-reference/sql-statements/account-management/GRANT.md
• administration/user_privs/authorization/User_privilege.md