query is running but failed to create view in biqquery - google-bigquery

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

Related

SQL (DB2) Creating table by selecting from other table

I´ve read several discussions and websites about creating a SQL query to create a table by selecting data from other table, but none of them solved my issue. I don´t know what else to do.
I am working on a SQL script to run a sequence of selects and creates do resume some data. I´ve been using this SQL queries on a SaS server using DB2 data. Now I need to migrate to Dbeaver to using other sources.
I just want to create a table by selecting some columns and data from other table, for this simple example :
"CREATE TABLE DB2XXXX.PaidResume AS
(SELECT HistoricalPaid.AccountNumber AS CONTA
FROM DB2XXX.HistPaid HistoricalPaid
WHERE HistoricalPaid.AccountNumber = 'XXXXX');
All I got it this error
Error occurred during SQL query execution
SQL Error [42601]: ILLEGAL SYMBOL "<END-OF-STATEMENT>". SOME SYMBOLS THAT MIGHT BE LEGAL ARE:. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.19.26
If I just exclude the "CREATE TABLE DB2XXXX.PaidResume AS" and run the select only, it works.
You must include WITH DATA or WITH NO DATA at the end of the SQL statement. For example:
create table u as (select a from t) with data;
See example at db<>fiddle.

How can i add query parameter to BigQuery add connect it to Data Studio?

In BQ I have saved view that connected to Data Studio. I need to add a parameter field to this view and control it from Data Studio.
Adding a dropdown list doesn't work, there is some complex calculations in BQ, i'm not getting the result i expected.
How i tried. Query, for example:
select *
from `project.dataset.table`
I added query parameter like this:
select *
from `project.dataset.table`
where subject = #subject
Then in Data Studio I added parameter field. But i'm getting this error message:
BigQuery error: Parameters are not supported; failed to parse view
How can I add parameter and connect view to Data Studio?
Use custom queries:
Choose Custom Query in BigQuery connector in Data Studio
Add the field as a parameter
BigQuery + DataStudio does support Query Parameter (as introduced here https://blog.google/products/marketingplatform/analytics/introducing-bigquery-parameters-data-studio/).
However, BigQuery itself doesn't support using using query parameter inside view definition. For now, you will have to leave the filter outside of the view.

Is there a way to use scripting methods in a saved view in BigQuery?

I am currently using a view in BigQuery to aggregate data from many different large tables. I then use this view to create a materialized flat table, with a MERGE statement to update it. However, the most recent LEFT JOIN I've added to the view caused the query that instantiates the materialized table to return the error: "Resources exceeded during query execution." The view right now is estimated to churn through 60GB of data.
To try to solve this issue, I tried using scripting to create temporary tables for the different subqueries in the view, thinking that this might save on resources. However, it appears that I am not able to save a view that uses scripting. Is there some way that this can be done?
I assume that is not supported today. I had the errors weeks ago and I bet that is due to beta version.
For answering the comment, a very simple query
DECLARE dummy STRING;
set dummy="not work";
select dummy
This simply answers not work. Try to create a view from this, I have an error Syntax error: Unexpected keyword DECLARE at [1:1]. Not a data error, not a query error, simply not supported!
Using stored procedure not help because you use "script" command CALL for calling your stored procedure.
For information, there is a feature request on this

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.

How to save a view in BigQuery - Standard SQL Dialect

I am trying to save a view using BigQuery's WebUI, which was created in Standard SQL Dialect, but I am getting this error:
Failed to save view. Bad table reference "myDataset.myTable"; table references in standard SQL views require explicit project IDs
Why is this error showing up? How can I fix it? Should the "Table ID" field of the "Save view" dialog include the project id? Or does this error appear because of the query itself? Just in case, the query is running without any problems.
Thanks for your help.
Your view has reference to myDataset.myTable - which is ok when you just run it as a query (for example in Web UI).
But to save it as a view you must fully qualify that reference as below
myProject.myDataset.myTable
So, just add project to that reference
Same reply, in other words
The issue is in this part of query: FROM com.table
When running query, it's fine to not fully specify the name of table like this:
com_company_app_beta_IOS.app_events_20180619
But to save the query as a view the FROM has to be like this:
`company-prod`.com_company_app_beta_IOS.app_events_20180619
You need the backticks around the `company-prod` because the - dash character is unsupported in object names.
The structure in BigQuery look like this:
bigquery ui
I had the same problem.
You'll need to use backticks around the the whole string project.dataset.view/table in both create and select statements:
create view company-prod.com_company_app_beta_IOS.YOUR_VIEW as
select * from company-prod.com_company_app_beta_IOS.app_events_20180619
Use backticks around string project.dataset.view