running parameterized bigquery via cell magic in jupyter notebook - google-bigquery

I've got a problem with pydatalab: I just installed it and normal querying and charting via cell magic works fine.
The wiki for pydatalab says, it's possible to add chart controls. But that wiki uses some old %%sql syntax instead of the new %%bq query one which don't work anymore.
Weird thing is, the following works fine:
%%bq execute -q tmp_result_na
parameters:
- name: name
type: STRING
value: 'value'
Thank you (in advance) very much for your help!

I found this open issue. It's not implemented right now....

Related

mongodb differences between clients

I'm very confused and I can't seem to find any explanations on the web. windowStart is a ISODate in my documents.
When using the mongodb-java-driver (via the mongoTemplate in Spring) the following works fine...
{windowStart : {$lt : new Date()}}
When I use MongoDb Compass GUI and type the above in the Filter it is marked as not valid. If I change it to...
{windowStart : {$lt : new Date('2018-10-01')}}
...then it is marked as valid and works
Another example...
{windowStart : {$gt : new Date(new Date('2018-10-01').getTime()+1000*60*60*24*64)}}
Does not work in mongodb-java-driver (via the mongoTemplate in Spring).
Does work in MongoDb Compass GUI
So I just can't work out what I can and cannot do. There is something I'm missing about how the client drivers work and the differences? I see lots of examples on the web for searching date ranges etc yet most don't work for me, so again I'm wondering what client they have been written for
In the below script, you will get data between the given date
{windowStart:{$gte:ISODate('2022-12-28'),$lte:ISODate('2022-12-29')}}

Sqldeveloper adds spaces between schema and object

The latest version of Sqldeveloper (18.3) seems to break autoformatting.
sample query
select * from hr.whatever;
in 18.2, the query would format to
select *
from hr.whatever;
now, sqldeveloper 18.3 (using the same settings) is formatting this to
select *
from hr . whatever ;
the spaces between schema and object are annoying - and I found no way of switching this off.
I tried to copy the default "custom formatting" from 18.2 to 18.3, however this does not help.
My formatting options:
Hope someone is able to point me to the proper formatting option to disable this.
This is a bug.
Happens when you upgrade to 18.3 AND if you -
If a customer has ever visited the Custom Format Page, and hit OK (not
Cancel) when leaving it (even though he never touch the Arbori code),
then the new Arbori program would be saved (with all the
consequences).
Consequences being what you see.
To get the formatter working as expected again, hit this button.
This bug has been fixed for version 18.4, due later this year.

Formatting SQL Query Inside an IPython/Jupyter Notebook

I want to show some SQL queries inside a notebook. I neither need nor want them to run. I'd just like them to be well formatted. At the very least I want them to be indented properly with new lines, though keyword highlighting would be nice too. Does a solution for this exist already?
If you set the cell as Markdown one you can write the sql query as code specifying the language (e.g. mysql)
``` mysql
SELECT *
FROM table_a AS a
LIMIT 10;
```
This produces:
It highlights the keywords. Unfortunately, it doesn't seem to deal with indentation which seems to be the main issue you are trying to deal with but maybe this helps.
If you - like me - find yourself here because you want to highlight (and run) the %%sql magic, you're best of with the technique of this answer. Posting it here cause it took me quite some time before I found the correct keywords to my answer :)
require(['notebook/js/codecell'], function(codecell) {
codecell.CodeCell.options_default.highlight_modes['magic_text/x-mssql'] = {'reg':[/^%%sql/]} ;
Jupyter.notebook.events.one('kernel_ready.Kernel', function(){
Jupyter.notebook.get_cells().map(function(cell){
if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;
});
});
I found that this fixed the issue I was having.
``` sql
Produced styled code in edit mode but not when the cell was run.
``` mysql
Produced correct styling

Custom Grid Query in Rally with Multiple OR Clauses

I'm trying to write a query in Rally that will show me all the defects for several projects, but every time I save the query I get the message "Could not parse: Error parsing expression -- expected ")" but saw "OR" instead."
Here is the actual query:
((((Project.Name = "Project A") OR (Project.Name = "Project B")) OR (Project.Name = "Project C")) OR (Project.Name = "Project D"))
I checked Rally's so-called Help and it seems to me that everything is set up correctly, but maybe I'm missing something?
Your query syntax and parentheses groupings look fine. I tested your exact string above in a Custom Grid and it parses fine - no "Could not parse..." error. Maybe compare the exact query you are using against your sample above? Complex AND's and OR's can definitely be frustrating. If you miss a parenthesis or spaces around operators, the query engine will complain.
fyi, I just found that doing a page reload in the browser forces the changed query expression to be evaluated, whereas simply saving the modified query does not reliably re-evaluate the changed query.
The symptom I observed was that query results continued to complain about the previous query string, even though I had replaced parts of the query with different named fields, etc. This made me suspect browser caching, and when flushing cache did not help, then I did browser page reload, which worked perfectly.
So if your browser page was reloaded between when you were having the problem and later when it started working, then this might explain why.
From About link: Rally Build: master-9274 , Browser Type: firefox/19.0, rv:19.0

Every velocity tool escape function working except url()?

I can get $esc.html to work, but not $esc.url, it just comes up literal even though I follow example at: http://velocity.apache.org/tools/devel/generic/EscapeTool.html
Interestingly enough, on that page the url() section's head is "$attrib.name" instead of url().
Any ideas?
Thanks.
Worked for me in Tools 2.0. Maybe you have old version?
$esc.url("bread & butter") = bread+%26+butter