Materialised View in Big Query - google-bigquery

I am creating a materialised view using below command :
CREATE MATERIALIZED VIEW project-id.dataset_id.TESTING AS
SELECT COUNT(*) FROM project-id.dataset_id.table;
Below is the error:
Syntax error: Expected keyword AS but got "-" at [1:31]
I guess it's because my project id is like this : project-id (example testing-project-dev).
How to resolve this ?

Moving the answer from comments to an answer: Add backticks.
CREATE MATERIALIZED VIEW `project-id.dataset_id.TESTING` AS
SELECT COUNT(*) FROM `project-id.dataset_id.table`;

Related

I am trying to create a table from 2 views connected by the minus operator returns erro ORA-00600: [KGL-heap-size-exceeded]

I can't create a table from a view consisting of 2 other views connected by a minus operator. I can create a table from a view that uses a table and a view connected by a minus operator. Is this a limitation of Oracle or is there another way to use 2 views and the minus operator to create a table.
Code:
CREATE TABLE AS SELECT * FROM VIEW_1 MINUS VIEW_2
--[Error] Execution (51: 1): ORA-00600: internal error code,
arguments: [KGL-heap-size-exceeded]
All ORA-600s are bugs. You can either create an SR with My Oracle Support, or find the issue already discussed, or find your own workaround.
That being said, your SQL is incorrect - after the MINUS you would need another SELECT * FROM
If you still have trouble after fixing this, check the view definitions to make sure there's no self-referencing/loop going on or other craziness (like a 100MB SQL statement). Your error indicates that Oracle spazzed out while parsing it.

Getting "Materialized view query contains unsupported feature." error while creating materialized view in BigQuery even with a simple query

I am getting "Materialized view query contains unsupported feature." error when I try to create a materialized view in the BigQuery even with a simple query.
I have read this article and understood the limitations that the BigQuery has in creating materialized views.
But the query I am trying doesn't seem to be falling under any of these limitations, yet I am getting unsupported feature error.
The query that I am trying:-
CREATE MATERIALIZED VIEW myproject.mydataset.my_mv_table AS (
SELECT
id
FROM
myproject.mydataset.my_base_table
limit 100
);
I am expecting a simple materialized view to be created with this above query. But I am just getting the unsupported feature error which can be seen in the below image.
I am not getting what I am doing wrong.
Can someone help me to understand what I am doing wrong or what I am missing?
limit 100 is causing the issue as it is not supported in a materialized view. You can remove it as it doesn't reduce cost or performance.

How to refresh Athena Views?

I have a table in Athena. New data gets added to S3 and this gives updated results when i run the Select statement. I have created a view on this select statement . But problem is the view does not give the updated results as given by Select query. Is there a way that the view gives the same result as a select query? How can i refresh the view in AThena. Please reply if anyone faced the issue and found a solution. Thanks in advance.
A view could have filters or where clauses that stop the full result set from coming. Assuming view was based on a query like create view some_vw as select * from table then all records should come through.

query is running but failed to create view in biqquery

I would like to create view by using multiple tables . While creating view getting "FAiled to save View , column not found do u mean that this column" but if you run the query . I am getting data. Can you please help to resolve this issue
Most likely you are missing project(s) to be specified in your query
You should fully qualify tables as
[project:dataset.table] if you are using Legacy SQL or
`project.dataset.table` if you are using Standard SQL

Getting an error: "Keyword ORDER not expected" when creating an AS400 view

I am using the System i Navigator in order to create a View.
My view is very simple:
SELECT MOMAST.ORDNO, MOMAST.FITEM
FROM AMFLIBT.MOMAST AS MOMAST
WHERE MOMAST.FITEM LIKE 'POS-%'
GROUP BY MOMAST.ORDNO,MOMAST.FITEM
ORDER BY MOMAST.FITEM,MOMAST.ORDNO
When clicking on OK button to creat the view, I am getting the following error:
SQL0199] Keyword ORDER not expected. Valid tokens: . Cause . . . . . : The keyword ORDER was not expected here. A syntax error was detected at keyword ORDER. The partial list of valid tokens is .
When I remove the ORDER BY statement, the view is being created successfully.
I need to create my view with the ORDER BY statement, how can I achieve this task with no errors?
A view is a relational table, and the relational model defines a table as a set of rows. Since sets are not ordered - by definition - the rows in a view are not ordered, either. Therefore, an ORDER BY clause in the view definition is meaningless. The SQL standard (SQL:2003) does not allow an ORDER BY clause in a subselect in a CREATE VIEW statement, just as it is not allowed in a CREATE TABLE statement.
In your case, I recommend creating the view without the ORDER BY statement, and using this statement when selecting from the view (not while creating it).