I would like to create a dynamic WHERE clause in my SELECT statement.
Looking through Google results and the InfluxDB documentation, I cannot find any mention of COALESCE or any equivalent/reasonable way to achieve this purpose.
What would be the preferred way to do this?
Python libraries that will emulate this will suffice for my purpose, but I would greatly prefer a pure "SELECT" example.
Related
I have a list of IPs that I want to filter out of many queries that I have in sumo logic. Is there a way to store that list of IPs somewhere so it can be referenced, instead of copy pasting it in every query?
For example, in a perfect world it would be nice to define a list of things like:
things=foo,bar,baz
And then in another query reference it:
where mything IN things
Right now I'm just copying/pasting. I think there may be a way to do this by setting up a custom data source and putting the IPs in there, but that seems like a very round-about way of doing it, and wouldn't help to re-use parts of a query that aren't data (eg re-use statements). Also their template feature is about parameterizing a query, not re-use across many queries.
Yes. There's a notion of Lookup Tables in Sumo Logic. Consult:
https://help.sumologic.com/docs/search/lookup-tables/create-lookup-table/
for details.
It allows to store some values (either manually once, or in a scheduled way as as a result of some query) with | save operator.
And then you can refer to these values using | lookup which is conceptually similar to SQL's JOIN.
Disclaimer: I am currently employed by Sumo Logic.
I have read a paper about materialized view selection in datawarehouse , and I have been trying to implement it in OBIEE, but the generated query from OBIEE are start using WITH Clause / CTE / Subquery factoring.
This query are not rewrited to materialized view as I expected, and its a similiar issue in this oracle community forum , but query rewrite work only when I create materialize view in base table on where clause as discussed in the paper above , but our generated obiee query use an extremely complex subquery factoring, then this won't make a significant increase in query speed.
I just want to know is it possible to implement query rewrite & materialized view in generated OBIEE query in terms of the discussion in the paper above ? Thanks.
Short answer: No. Longer answer: No, because that's not how the product is built. It's meant to be a source-agnostic query generator and analytics platform, not a programming platform to let you develop queries on your own. You need to understand how the product works, hoe IT optimizes queries and chooses its sources. There are literally dozens of ways to influence how your query is getting written but they are all semantic/structural configuration options. You do not write code in OBI.
Join is described as pseudo-Join, because it's more equivalent to an SQL inner-query.
Whereas BlockJoin is described as more like a SQL join but requiring a sophisticated indexing schema, one that anticipates all the possible joins you'd want to make.
Could someone explain the difference between these features in terms of how to implement them at index time and query time. And what are the implications for performance?
I don't think blockjoinquery is a Solr function. I think its Lucene feature.
The solr join doesn't score documents in the from query and it doesn't return combined results. So its best used as a filter query. This will allow the main query.to score.
Block join on the other hand does use scoring and returns both results.( not 100% sure)
You can also use querytime join. This has serval scoring options. This is also a lucene feature but doesn't require special indexing blocks. I've used this in combination with a solr query parser plugin. The performance is a bit lower then blockjoin but it Works.
I have only used solr join and querytimejoin So I can't really say much about blockjoin.
As I understand, BlockJoin is for joining against nested/child documents within the same core. Join is for joining against a separate core.
Is it possible to do something like the following in lucene? If not, can you give any suggestions for how to get around this limitation?
SELECT
start.dt AS eventstarttime,
last.dt AS eventfinishtime
WHERE
start.evt:"Started" AND last.evt:"Ended" AND start.evtgrpid = last.evtgrpid
Your question does not give enough information to fully answer it. This SQL is not even valid - where is the FROM clause (for a start)?
Suggestion 1: run two queries ("Started" and "Ended") separately and merge the results based on evtgrpid.
Suggestion 2: run one query (e.g. "Started") and filter the results based on "Ended" criteria.
Suggestion 3: do not use Lucene for what databases are built for. Really. Often database logic does not even apply to Lucene (e.g. what if stopwords are used when indexing?).
I'm making a bunch of YQL queries at once & have a standard way of accessing the fields on the server. Unfortunately one of the feeds uses a different name than the rest for a field so I was assuming I could alias it within YQL.
Something like:
SELECT title, link, encoded AS description FROM...
But it looks like YQL's parser doesn't like that as I get this error:
Syntax error(s) [line 1:37 expecting field got 'AS']
So, is it possible to alias fields in YQL like you can in SQL? I don't seen anything in the YQL docs or on the internet at large.
Tacking another (small) question on as well, is there a spec anywhere for YQL's syntax?
No, it's not possible to do an alias in the YQL query. (As #codeulike mentioned, it's really not true "SQL" like you might find in MySQL or other databases.)
One capability that might help your needs is the ability in Open Tables to create an alias for parameter names. See the YQL Open Tables documentation and search for "alias".
I think YQL corresponds to SQL in only a metaphorical sort of way; although it superficially uses things like SELECT, it doesn't try to cover much of the breadth of SQL. Hence if its not in the documentation, its probably not possible.
In this guide: http://developer.yahoo.com/yql/guide/select_statement.html ... aliasing of fields is not mentioned, so I figure its not a feature.
Although, if you run your YQL query through Yahoo Pipes, you can use their Rename module to rename elements of the data.