Alter a Redshift View to point to a new table - amazon-web-services

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.

Related

extra table is created after creating a Redshift Materialized view

Created a redshift materialized view (view name: lirt_cases_mv) to use external schema. However, this extra table is created mv_tbl__lirt_cases_mv__0. Does anyone know why this extra table is created? Is there a way to prevent creating this extra table?
Thank you for your help.
I found this article that attempts to explain the process of Materialized View refreshes under the hood in Redshift. Here is what the article suggests:
A stored procedure called mv_sp__house_price_mvw__0_0 is invoked
As part of the procedure, a backup table called mv_tbl__house_price_mvw__0__tmp is created using the materialized view query
A view called house_price_mvw is create/replaced using the _tmp table
The table mv_tbl__house_price_mvw__0 is dropped
The _tmp table is renamed to mv_tbl__house_price_mvw__0
The house_price_mvw view is create/replaced based on mv_tbl__house_price_mvw__0
If this is correct, then mv_tbl__lirt_cases_mv__0 would be the source object responsible for create/replacing your materialized view lirt_cases_mv, and I don't think there would be any way around having it.
I've not verified that everything the author says in this article is true, but you can reproduce and verify for yourself by querying from svl_statementtext after performing a full refresh of the materialized view.

Do views of tables in BigQuery benefit from partitioning/clustering optimization?

We have a few tables in BigQuery that are being updated nightly, and then we have a deduplication process doing garbage collection slowly.
To ensure that our UI is always showing the latest, we have a view setup for each table that simply does a SELECT WHERE on the newest timestamp record_id combination
We're about to setup partitioning and clustering to optimize query scope/speed and I couldn't find a clear answer in Google documentation on whether the view of that table will still have partitioned queries or it will end up querying all data.
Alternatively when we create the view, can we include the partition and cluster on in the query that builds the view?
If you're talking about a logical view, then yes if the base table it references is clustered/partitioned it will use those features if they're referenced from the WHERE clause. The logical view doesn't have its own managed storage, it's just effectively a SQL subquery that gets run whenever the view is referenced.
If you're talking about a materialized view, then partitioning/clustering from the base table isn't inherited, but can be defined on the materialized view. See the DDL syntax for more details: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_materialized_view_statement

How to provide permission to the user to access only one column in the created Microsoft Lists?

Am new to Microsoft Lists and trying to implement the library management system. Have prepared a list to show the book details using the 'From Excel' list. Need to restrict the permission based on the user role(admin, client).
For example, If a user needs to request a book, there might be a column to access for the user to send a request for the desired book. So that, an admin will get notified for the request and take action.
Similarly, from the list i created, i need to provide permission to the user to access only one column. The rest of the column can only be for view purposes.
Note: As i searched i found we can set permission like view, view, and edit, and stop sharing the list based on the roles of Members, Owners, and Visitors.
Could anyone please guide me on this?
Regards,
Vadivel
#Karthi,
It's not possible to configure column permission, the least permission is item-level. There is no column-level or view level permission.
Here are 2 possible solutions:
Make the target column read-only. Then develop another interface for the administrator to manage the data. For example, through SharePoint rest API, we can turn the column back to editable and post updates then immediately turn it to read-only.
Check Set List Column Read Only in SharePoint using PowerShell
How to update read only field
Hide the target column and make a calculated column then set its value equal to the target column. The user will only see those calculated columns, any updates on the target column will be reflected in calculated columns.
Check Make SharePoint Columns read-only without coding

BigQuery create view based on future tables using wildcard expresssion

Using terraform, I'm trying to create a view that is responsible of consolidating multiple system tables into a single 'master' system table, e.g.,
system_system1
system_system2
...
The following query is used to create the view:
SELECT * except(non_shared_cols) FROM `project.dataset.system_*`
This works as expected, and downstream components can use the master table to compute metrics. However, most of the tables do not exist at creation time of the view, hence I'm getting the following error:
project:dataset.system_* does not match any table.
I assumed the view would be resolved at query time, but apparently this is not the case. Is there any other BigQuery concept I could rely on to create this view?
Or is this just some kind of a safety check which I can avoid somehow?
I could ofcourse create a 'dummy' table in Terraform, but this seems really tedious as I need to know the shared schema of the BigQuery tables in advance.

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.