statement ok
SET RW_IMPLICIT_FLUSH TO true;

statement ok
ALTER SYSTEM SET license_key TO '';

statement ok
flush;

statement ok
CREATE TABLE t (k INT);

statement error feature SinkSinceTimestamp is not available based on your license
CREATE SINK since_timestamp_sink
FROM
  t
WITH
(
  connector = 'blackhole',
  snapshot = 'false',
  since_timestamp = '2024-01-01 00:00:00Z'
);


statement error
CREATE SINK dynamodb_sink
FROM
  t
WITH
(
  connector = 'dynamodb',
  table = 'xx',
  primary_key = 'k',
  region = 'xx',
  access_key = 'xx',
  secret_key = 'xx'
);
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: feature DynamoDbSink is not available based on your license

Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. For more information, visit https://go.risingwave.com/premium.


statement error
CREATE SINK redis_sink
FROM
    t WITH (
    primary_key = 'k',
    connector = 'redis',
    redis.url= 'redis://127.0.0.1:6379/',
)FORMAT PLAIN ENCODE TEMPLATE(force_append_only='true',stream='aaa', key_format = 'key_is:{k}', redis_value_type ='stream', value_format = 'jafk:{k}_');
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: feature RedisSinkStream is not available based on your license

Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. For more information, visit https://go.risingwave.com/premium.


statement error
CREATE SINK snowflake_sink
FROM t
WITH (
    connector = 'snowflake',
    type = 'append-only',
    force_append_only = 'true',
    s3.bucket_name = 'xx',
    s3.credentials.access = 'xx',
    s3.credentials.secret = 'xx',
    s3.region_name = 'xx',
    s3.path = 'xx',
);
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: feature SnowflakeSink is not available based on your license

Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. For more information, visit https://go.risingwave.com/premium.


statement error
CREATE SINK opensearch_sink
FROM t
WITH (
    connector = 'opensearch',
    url = 'xx',
    username = 'xx',
    password = 'xx',
);
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: feature OpenSearchSink is not available based on your license

Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. For more information, visit https://go.risingwave.com/premium.


statement error
CREATE SINK bigquery_sink
FROM
  t
WITH
(
  connector = 'bigquery',
  type = 'append-only',
  force_append_only='true',
  bigquery.local.path= 'xx',
  bigquery.project= 'xx',
  bigquery.dataset= 'xx',
  bigquery.table= 'xx'
);
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: feature BigQuerySink is not available based on your license

Hint: You may want to set a license key with `ALTER SYSTEM SET license_key = '...';` command. For more information, visit https://go.risingwave.com/premium.


statement ok
ALTER SYSTEM SET license_key TO DEFAULT;

statement ok
flush;

statement error
CREATE SINK dynamodb_sink
FROM
  t
WITH
(
  connector = 'dynamodb',
  table = 'xx',
  primary_key = 'xx',
  region = 'xx',
  access_key = 'xx',
  secret_key = 'xx'
);
----
db error: ERROR: Failed to run the query

Caused by:
  Invalid input syntax: Sink primary key column not found: xx. Please use ',' as the delimiter for different primary key columns.


statement error
CREATE SINK snowflake_sink
FROM t
WITH (
    connector = 'snowflake',
    type = 'append-only',
    force_append_only = 'true',
    s3.bucket_name = 'xx',
    s3.credentials.access = 'xx',
    s3.credentials.secret = 'xx',
    s3.region_name = 'xx',
    s3.path = 'xx',
    primary_key = 'xx',
);
----
db error: ERROR: Failed to run the query

Caused by:
  Invalid input syntax: Sink primary key column not found: xx. Please use ',' as the delimiter for different primary key columns.


statement error
CREATE SINK opensearch_sink
FROM t
WITH (
    connector = 'opensearch',
    url = 'xx',
    username = 'xx',
    password = 'xx',
    index = 'xx',
);
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: ElasticSearch/OpenSearch error
  4: relative URL without a base


statement error
CREATE SINK bigquery_sink
FROM
  t
WITH
(
  connector = 'bigquery',
  type = 'append-only',
  force_append_only='true',
  bigquery.local.path= 'xx',
  bigquery.project= 'xx',
  bigquery.dataset= 'xx',
  bigquery.table= 'xx'
);
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: BigQuery error
  4: No such file or directory (os error 2)


statement error
CREATE SINK redis_sink
FROM
    t WITH (
    primary_key = 'k',
    connector = 'redis',
    redis.url= 'redis://127.0.0.1:6379/',
)FORMAT PLAIN ENCODE TEMPLATE(force_append_only='true',stream='aaa', key_format = 'key_is:{k}', redis_value_type ='stream', value_format = 'jafk:{v1}_');
----
db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
  1: gRPC request to meta service (call `/ddl_service.DdlService/CreateSink`) failed: Internal error
  2: failed to validate sink
  3: Redis error: Can't find field("v1") in key_format or value_format


statement ok
DROP TABLE t;
