Getting all references to a view within a project on BigQuery - google-bigquery

Given a view or a table, how can I list views and scheduled queries having a reference to it within a project?
I understand from the documentation that I can do check reference within a dataset with below query, but I'd like to check reference within a project all at once.
SELECT *
FROM your_dataset_name.INFORMATION_SCHEMA.VIEWS
WHERE REGEXP_CONTAINS(view_definition, 'your_dataset_name.your_table_name')

Related

How do I correctly use report-level filters in Power BI?

I am fairly new to Power BI and working on my first project. I currently have two separate sql views setup and connected to my project as well as a simple visual for each one. They both share a common field that I want to filter on, call it customer_key. I tried adding a filter to the "Filters on all pages" section but it doesn't seem to filter both visuals, only the one I dragged the field from. I ultimately want to do the same thing with a date field so that this report can be easily re-ran for any of our customers and any date range. Suggestions?
I would like to have a single filter that affects all data sets in my report, provided they have that column to filter on. Currently, I am using separate filters for each data set (even though I moved the filter to the "Filters on all pages" section).
This happens when the "common" customer_key columns are not related. So you have to set up a relation between your two sql views. However, if both are fact tables this is not straight forward, since you would end up with a many-to-many relation.
Workaround: Extract the unique customer_key values from both views and create a third dim table from it. Now you can create two one-to-many relations to your sql views and use the third table customer_key as a report-level filter.
You can create the connecting dim table with the following DAX table expression:
Table3 =
DISTINCT(
UNION(
SELECTCOLUMNS(
'Table1',
"customer_key", 'Table1'[customer_key]
),
SELECTCOLUMNS(
'Table2',
"customer_key", 'Table2'[customer_key]
)
)
)

How to reference the latest table from a manually partitioned BigQuery table

We have a manually partitioned "video metadata" table being fed fresh data each day. In our system, old data is only kept for historical reasons since the latest data is the most up to date.
What we cant figure out is how to reference only the latest partition in this table using LookML.
So far we have attempted to store views in BigQuery. We have tried and failed to store a simple "fetch the newest partition" query as a view, in both standard and legacy SQL, and upon some searching, this seems to be by design, even though the error message states "Dataset not found" instead of something more relevant.
We've also tried to build the filtering into Looker, but we're having trouble with getting things to actually work and only having the latest data returned to us through it.
Any help would be appreciated.
We've managed to find a solution, derived tables
We figured that since we couldn't define a view on BigQuery's side, we could do it on Looker's side instead, so we defined the table in a derived table block inside a view.
derived_table: {
sql: SELECT * FROM dataset.table_*
WHERE _TABLE_SUFFIX = (
SELECT max(_TABLE_SUFFIX) FROM dataset.table_*
);;
sql_trigger_value: SELECT max(_TABLE_SUFFIX) FROM dataset.table_*;;
}
This gave us a view with just the newest data in it.

How to Retrieve a Custom Event Name in Azure Stream Analytics

I created a custom event that is tracked by Azure Application Insights. It has a few custom data properties I am able to successfully track, as well as 2 custom event properties of interest (one of which I cannot display).
The one I cannot successfully query is the event name. I'm trying to reference it in the query by using event.name, but it's returning null for all records, even though I know for sure the names are not actually null.
If anyone knows the proper way to query the custom event's name, please let me know! I can't find it on: https://learn.microsoft.com/en-us/azure/application-insights/app-insights-export-data-model
The issue here is name is in an array, so event.name returns NULL since it doesn't exist.
Will you always have only 1 name in this array?
If so the following query will extract that value:
SELECT GetRecordPropertyValue(GetArrayElement(event, 0),'name') as eventName from input
If you have various names, the query will depend of the logic (hence the suggestion to use CROSS APPLY).

Finding the query that created a table in BigQuery

I am a new employee at the company. The person before me had built some tables in BigQuery. I want to investigate the create table query for that particular table.
Things I would want to check using the query is:
What joins were used?
What are the other tables used to make the table in question?
I have not worked with BigQuery before but I did my due diligence by reading tutorials and the documentation. I could not find anything related there.
Brief outline of your actions below:
Step 1 - gather all query jobs of that user using Jobs.list API - you must have Is Owner permission for respective projects to get someone else's jobs
Step 2 - extract only those jobs run by the user you mentioned and referencing your table of interest - using destination table attribute
Step 3 - for those extracted jobs - just simply check respective queries which allow you to learn how that table was populated
Hth!
I have been looking for an answer since a long time.
Finally found it :
Go to the three bars tab on the left hand side top
From there go to the Analytics tab.
Select BigQuery under which you will find Scheduled queries option,click on that.
In the filter tab you can enter the keywords and get the required query of the table.
For me, I was able to go through my query history and find the query I used.
Step 1.
Go to the Bigquery UI, on the bottom there are personal history and project history tabs. If you can use the same account used to execute the query I recommend personal history.
Step 2.
Click on the tab and there will be a list of queries ordered from most recently run. Check the time the table was created and find a query that ran before the table creation time.
Since the query will run first and create the table there will be slight differences. For me it stayed between a few seconds.
Step 3.
After you find the query used to create the table, simply copy it. And you're done.

Check if a given DB object used in Oracle?

Hi does any one know how to check if a given DB object (Table/View/SP/Function) is used inside Oracle.
For example to check if the table "A" is used in any SP/Function or View definitions. I am trying to cleanup unused objects in the database.
I tried the query select * from all_source WHERE TEXT like '%A%' (A is the table name). Do you thing it is safe to assume it is not being used if it does not return any results?
From this ASKTOM question:
You'll have to enable auditing and then come back in 3 months to see.
We don't track this information by default -- also, even with auditing, it may be very
possible to have an object that is INDIRECTLY accessed (eg: via a foreign key for
example) that won't show up.
You can try USER_DEPENDENCIES but that won't tell you about objects referenced by code in
client apps or via dynamic sql
There's code in the thread for checking ALL_SOURCE, but it's highlighted that this isn't a silver bullet.