I am trying to create an Glue virtual view (table_type = "VIRTUAL_VIEW"), through which I can query through Athena. I am doing this through Terraform. I am able to successfully create the Glue view using below Terraform code, but then it fails as below error (INVALID_VIEW: Invalid view JSON: SELECT id, module, projectid FROM test_data."test_metrics" limit 10). I am not sure what I am doing wrong here, I guess it is it something to do with the way I am passing query to the VIEW, but tried few ways, but in vain. Any help would gretaly be appreciated :). Thank you.
locals {
database = "test_data"
query = "SELECT id, \nmodule, \nprojectid FROM ${local.database}.\"test_metrics\" limit 10"
}
resource "aws_glue_catalog_table" "story_view" {
database_name = local.database
name = "story_flow_details"
table_type = "VIRTUAL_VIEW"
view_original_text = "/* Presto View: ${base64encode(local.query)} */"
view_expanded_text = "/* Presto View */"
parameters = {
presto_view = "true"
comment = "Presto View"
}
storage_descriptor {
ser_de_info {
name = "JsonHiveSerDe1"
serialization_library = "org.apache.hive.hcatalog.data.JsonSerDe"
}
columns {
name = "id"
type = "string"
}
columns {
name = "module"
type = "string"
}
columns {
name = "projectid"
type = "string"
comment = ""
}
}
}
Your query has the following error(s): INVALID_VIEW: Invalid view JSON: SELECT id, module, projectid FROM test_data."test_metrics" limit 10; This query ran against the "test_data" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: 79231ddc-d77c-4660-bf70-b84009a82082.