Hi Team, I have Iceberg External table with schema...
# questions-and-troubleshooting
v
Hi Team, I have Iceberg External table with schema
```CREATE TABLE audit_logs (
user_id STRING,
action STRING,
event_time TIMESTAMP,
tags ARRAY<STRING>,
metadata MAP<STRING, STRING>,
container ROW<
ip STRING,
ua STRING,
headers MAP<STRING, STRING>,
params ARRAY<ROW<key STRING, property STRING>>
>,
shard_id STRING
)
PARTITIONED BY (shard_id);```
I am trying to create the MV on top of it using following query
```CREATE MATERIALIZED VIEW mv_audit_logs_recent
PARTITION BY shard_id
DISTRIBUTED BY HASH(user_id)
ORDER BY (event_time)
REFRESH MANUAL
PROPERTIES (
"replication_num" = "1"
)
AS
SELECT
user_id,
action,
event_time,
tags,
metadata,
container,
shard_id
FROM audit_log_iceberg.audit_log_db.audit_logs
WHERE event_time<=current_date()
AND event_time>=date_add(current_date(), INTERVAL -30 DAY);```
MV got created successfully, but I am getting error while performing refresh operations
Error:  INVALID: no valid plan: MV contains non-deterministic functions(current_date)
As per the docs it should be possible: https://docs.starrocks.io/docs/using_starrocks/async_mv/use_cases/data_lake_query_acceleration_with_materialized_views/#case-four-se[…]-in-data-lake. This example used current_date() func. I checked in the code base, it says current_date and current_timestamp as non-deterministic funcs: https://github.com/StarRocks/starrocks/blob/416ca516cdcacb2f3726d21a21dbc2dfd98701[…]ore/src/main/java/com/starrocks/sql/analyzer/AnalyzerUtils.java Can someone please help here?
е
tried to reproduce your case first thing - error creating table
Copy code
mysql> CREATE TABLE audit_logs (
    ->     user_id STRING,
    ->     action STRING,
    ->     event_time TIMESTAMP,
    ->     tags ARRAY<STRING>,
    ->     metadata MAP<STRING, STRING>,
    ->     container ROW<
    ->        ip STRING,
    ->        ua STRING,
    ->        headers MAP<STRING, STRING>,
    ->        params ARRAY<ROW<key STRING, property STRING>>
    ->     >,
    ->     shard_id STRING
    -> )
    -> PARTITIONED BY (shard_id);
ERROR 1064 (HY000): Getting syntax error at line 4, column 15. Detail message: Unexpected input 'TIMESTAMP', the most similar input is {'TIME', 'BITMAP', 'TEXT', 'TINYINT', 'DATETIME'}.
so i did datetime
Copy code
mysql> CREATE TABLE audit_logs (     user_id STRING,     action STRING,     event_time datetime, shard_id STRING ) ;
Query OK, 0 rows affected (0.62 sec)
and no error for mv
Copy code
mysql> CREATE MATERIALIZED VIEW mv_audit_logs_recent DISTRIBUTED BY HASH(user_id)
    -> REFRESH MANUAL
    -> PROPERTIES (
    ->  "replication_num" = "1"
    -> )
    -> AS
    -> SELECT
    ->     user_id,
    ->     action,
    ->     event_time,
    -> shard_id
    -> FROM audit_logs WHERE event_time<=current_date()
    -> AND event_time>=date_add(current_date(), INTERVAL -30 DAY);
Query OK, 0 rows affected (0.31 sec)
v
I used the FlinkSQL to create the External Iceberg Table.
For me Mv got created successfully. It was failing during refresh operation. Refresh operation working fine for you?
е
ah, i overlooked it, suppose you are right on this
👍 1
v
Hmm, then its not supported. Document is incorrect. I'll raise an issue on GH.
🙏 1