apache / gravitino

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
https://gravitino.apache.org
Apache License 2.0
1.1k stars 348 forks source link

[Bug report]Failed to drop schema include special characters "-",while create api support to create the schema include "-" #2634

Closed danhuawang closed 7 months ago

danhuawang commented 8 months ago

Version

main branch

Describe what's wrong

curl -X GET  -H "Content-Type: application/json" http://13.115.24.251:8090/api/metalakes/pm/catalogs/mysql_2/schemas/s_test_4586740f-f909-4864-9abb-4ed905d40250 -s -w ‘%{time_connect}:%{time_starttransfer}:%{time_total}’

{"code":0,"schema":{"name":"s_test_4586740f-f909-4864-9abb-4ed905d40250","properties":{"COLLATE":"utf8mb4_0900_ai_ci","CHARACTER SET":"utf8mb4"},"audit":{}}}‘0.045080:0.249198:0.249349’%

curl -X DELETE  -H "Content-Type: application/json" http://13.115.24.251:8090/api/metalakes/pm/catalogs/mysql_2/schemas/s_test_4586740f-f909-4864-9abb-4ed905d40250 -s -w ‘%{time_connect}:%{time_starttransfer}:%{time_total}’

{"code":1002,"type":"RuntimeException","message":"Failed to operate object [s_test_4586740f-f909-4864-9abb-4ed905d40250] operation [DROP] under [mysql_2], reason [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-f909-4864-9abb-4ed905d40250' at line 1]","stack":["java.lang.RuntimeException: com.datastrato.gravitino.exceptions.GravitinoRuntimeException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-f909-4864-9abb-4ed905d40250' at line 1","\tat com.datastrato.gravitino.catalog.CatalogOperationDispatcher.doWithCatalog(CatalogOperationDispatcher.java:754)","\tat com.datastrato.gravitino.catalog.CatalogOperationDispatcher.dropSchema(CatalogOperationDispatcher.java:348)","\tat com.datastrato.gravitino.server.web.rest.SchemaOperations.lambda$dropSchema$9(SchemaOperations.java:185)","\tat com.datastrato.gravitino.lock.TreeLockUtils.doWithTreeLock(TreeLockUtils.java:35)","\tat com.datastrato.gravitino.server.web.rest.SchemaOperations.lambda$dropSchema$10(SchemaOperations.java:184)","\tat java.security.AccessController.doPrivileged(Native Method)","\tat javax.security.auth.Subject.doAs(Subject.java:422)","\tat com.datastrato.gravitino.utils.PrincipalUtils.doAs(PrincipalUtils.java:25)","\tat com.datastrato.gravitino.server.web.Utils.doAs(Utils.java:121)","\tat com.datastrato.gravitino.server.web.rest.SchemaOperations.dropSchema(SchemaOperations.java:179)","\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"

Error message and/or stacktrace

N/A

How to reproduce

N/A

Additional context

No response

yuqi1129 commented 7 months ago

@danhuawang This issue can't be reproduced in the main branch now(7/4/2024), do I miss something?

➜  [/Users/yuqi/Downloads/package] curl -X POST -H "Content-Type: application/json" -d '{"name":"s_test_4586740f-f909-4864-9abb-4ed905d40250"}' http://localhost:8090/api/metalakes/test/catalogs/mysql_catalog/schemas
{"code":0,"schema":{"name":"s_test_4586740f-f909-4864-9abb-4ed905d40250","properties":{"COLLATE":"utf8mb4_0900_ai_ci","CHARACTER SET":"utf8mb4"},"audit":{"creator":"anonymous","createTime":"2024-04-07T11:14:57.345268Z"}}}%
➜  [/Users/yuqi/Downloads/package] curl -X GET http://localhost:8090/api/metalakes/test/catalogs/mysql_catalog/schemas/s_test_4586740f-f909-4864-9abb-4ed905d40250
{"code":0,"schema":{"name":"s_test_4586740f-f909-4864-9abb-4ed905d40250","properties":{"COLLATE":"utf8mb4_0900_ai_ci","CHARACTER SET":"utf8mb4"},"audit":{}}}%
➜  [/Users/yuqi/Downloads/package] curl -X DELETE http://localhost:8090/api/metalakes/test/catalogs/mysql_catalog/schemas/s_test_4586740f-f909-4864-9abb-4ed905d40250\?cascade\=true
{"code":0,"dropped":true}%
danhuawang commented 7 months ago

curl -X DELETE http://localhost:8090/api/metalakes/test/catalogs/mysql_catalog/schemas/s_test_4586740f-f909-4864-9abb-4ed905d40250\?cascade\=true

curl -X DELETE http://localhost:8090/api/metalakes/test/catalogs/mysql_catalog/schemas/s_test_4586740f-f909-4864-9abb-4ed905d40250\?cascade\=true

@yuqi1129 Why "\?cascade\=true" is required in your command? Our doc in mysql catalog part says "Doesn't support cascade dropping schema."

curl -X DELETE http://localhost:8090/api/metalakes/test/catalogs/mysql_catalog/schemas/s_test_4586740f-f909-4864-9abb-4ed905d40250
yuqi1129 commented 7 months ago

Confirm, it's a bug.