Adding comments for columns to a view in Athena (Presto) - amazon-athena

After creating a view in Athena (Presto), I would like to add a comment for each column and also a comment for the view itself. Looking at the AWS official documentation, I can't find any reference for this. Any ideas?

Related

how to create view in athena view using pyspark?

I have try to create view in athena using pyspark like below.
spark.sql("CREATE OR REPLACE VIEW work.test_view123 AS SELECT emp_name,emp_no FROM emp.emp_table")
But I am not able to see view in work db.
I think you need to use the SDK to get a reference to the Athena API and use it to execute a query with the create view statement.

Alter a Redshift View to point to a new table

I've created a simple view in Redshift that is select * from source_a with no schema binding. Now I have a new table, source_b, that I would like the view to point to instead that has no new columns or datatypes.
How can I repoint the view without dropping permissions?
You run the CREATE again but include the OR REPLACE syntax.
CREATE OR REPLACE VIEW my_view AS …
WITH NO SCHEMA BINDING ;
You can retrieve the existing view definition with pg_get_viewdef.
SELECT pg_get_viewdef('my_view', true);
First off take a look at the create view documentation page - https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_VIEW.html
You have made a late-binding view which checks permissions on the tables when executed so you need to make sure you have the correct permissions on that new table - "source_b". These late-binding views are a the lookup / reference to the tables rather than a predefined link in the database. You also cannot grant column lever access to a late binding view. Otherwise permissions work the same as regular views.
To change the view without having to change the permissions on it you will want to use "create or replace view ..." (see link above) to update the definition. Just remember that the permissions of the new table will matter.

Can you specify column descriptions for a view in a DDL statement in BigQuery?

I know this is possible with a CREATE TABLE statement but I don't see a way to do it with views. I know views support descriptions on columns since I can edit them in the web GUI. I'd like to avoid deploying views with a separate "annotation" file if possible.
I'd like to do something like the following
CREATE VIEW Sandbox.vtest
as
SELECT 1 AS TestField [WITH] OPTIONS(description="An INTEGER field")
This would also work especially now that scripting is possible
ALTER VIEW Sandbox.vtest
ALTER COLUMN TestField
SET OPTIONS(description="An INTEGER field")
If it's not possible I'm hoping someone from Google could comment on any future plan to add this functionality. That could at least guide my CI/CD development.
This is not currently possible, but you could consider submitting a feature request. Use this link: https://issuetracker.google.com/issues/new?component=187149&template=0
After you create a logical view, you can navigate to it in the BigQuery UI and then set the description or other attributes.

BigQuery Cannot Modify Partitioned Table Schema

Per the BigQuery documentation I am attempting to modify a table's schema by adding a field. The table in question is a partition slice (partitioned by day). I am planning on performing the action on every slice.
Per the documentation (https://cloud.google.com/bigquery/docs/managing-partitioned-tables), I should be able to add field to a partitioned table like any other table. However whenever I attempt to add a field to a partitioned table, I am met with this error:
Could not edit table schema.: Cannot change partitioned/clustered table to non partitioned/clustered table.
I am not able to find any good information on what this error means, or what I'm doing wrong. I have successfully added a field to a non-partitioned table. Does the community have any good ideas to help me troubleshoot?
I understand that you are using the update_table method to update the schema in python, correct me if I'm wrong. You have to do it with the patch API you can try this API to have a better view on how to do it.

Can you create views in Amazon Athena?

Is it possible to create views in Amazon Athena?
Since an External table is essentially metadata for data stored in files on S3, there's no transformation involved. Therefore, you can't handle data inconsistencies. Quite often, this can result in tables being defined with lots of string fields.
Can you create a view over the top of the External table that can contain the transformation logic, allowing users to query a "cleansed" view of the data?
Looks like they have added this support now AWS Doc
While that is a nice feature that you are looking for,
AWS Athena does not support creating any view.
Reference Documentation of supported DDL's:
http://docs.aws.amazon.com/athena/latest/ug/language-reference.html
Hope it helps.