Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
simple udf implementation in 'select' clause not working but working in 'where' clause
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Fayaz Aziz  
View profile  
 More options Jul 25 2012, 5:05 am
From: Fayaz Aziz <fayaz.a...@gmail.com>
Date: Wed, 25 Jul 2012 02:05:59 -0700 (PDT)
Local: Wed, Jul 25 2012 5:05 am
Subject: simple udf implementation in 'select' clause not working but working in 'where' clause

ql io script :
var script = 'u = require("./myUDF.js");\
create table myoffers on select get from "
https://api.sqoot.com/v1/offers?affiliate_token={^token}&location={mylocation}&order={^orders}&page={^page}&per_page={^psiz e}"\
using headers accept = "*/*" \
using defaults token = "xxxxx", orders = "score", page = "1", psize = "3" \
resultset "offers" ' \

select offer.title as mytitle, *u.getGoogleID(10)* as loc from myoffers
where mylocation = 'sanfransico'

my udf function :

var util = require('util');

exports.getGoogleID = function (id) {
return this.next(null, id+10);

}

*WHAT I AM MISSING HERE ?... my result is
{ title: 'The best of Heering at 50%.', loc: undefined } // the loc value should be 20
SOMEHOW I AM UNABLE TO ENTER IN MY UDF FUNCTION...... what is the possible reason for that ?*

*Does this udf functionality implementing in 'select' clause as it was working in my where clause ??*


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
shimonchayim  
View profile  
 More options Jul 25 2012, 2:19 pm
From: shimonchayim <shimoncha...@gmail.com>
Date: Wed, 25 Jul 2012 11:19:19 -0700 (PDT)
Local: Wed, Jul 25 2012 2:19 pm
Subject: Re: simple udf implementation in 'select' clause not working but working in 'where' clause

Right now udf only works in where only. Functionally if you plan to use udf
in select for data transformation you can also do that through the udf in
where. That is the main reason we haven't given udf in select higher
priority.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fayaz Aziz  
View profile  
 More options Jul 30 2012, 3:47 am
From: Fayaz Aziz <fayaz.a...@gmail.com>
Date: Mon, 30 Jul 2012 00:47:18 -0700 (PDT)
Local: Mon, Jul 30 2012 3:47 am
Subject: Re: simple udf implementation in 'select' clause not working but working in 'where' clause

hmm but my udf function is depend on the parameter that is provided in
select clause like

select name, id , myfunction(id) from table ABC
how can i use this in where clause, herei need to mapped the id from the
current table and in my udf function i need to call another ql.io script
which takes the id as param.. so by using it in select clause it will map
one by one.

AND

Can you please also tell me the main difference b/w udfs and monkey patches
and some use cases of both (when to use what).. i need to perform some
execution of ql.io script in my monkey patch file.. it is right way to do
?? Knowing that the udf is currently not enough mature.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
shimonchayim  
View profile  
 More options Jul 30 2012, 2:03 pm
From: shimonchayim <shimoncha...@gmail.com>
Date: Mon, 30 Jul 2012 11:03:36 -0700 (PDT)
Local: Mon, Jul 30 2012 2:03 pm
Subject: Re: simple udf implementation in 'select' clause not working but working in 'where' clause

Pardon for answering your question in the reverse order Monkey patches are
part of table definition (more about them here:
http://ql.io/docs/monkey-patch)

On your first question:

Let us consider sample udf:

exports.mergeResult = function() {
var id = this.row.id;
var name = this.row.name;
var result = do_something(id, name);
this.row = result;
return this.next(null, this.row);

}

You can modify the row returned to your desire. So Udf in "where" does
filtering as well as transformation.

I wouldn't advise you to call ql.io scripts from udf or monkeypatch. These
scripting hooks are for executing light logic and not for IO.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fayaz Aziz  
View profile  
 More options Jul 31 2012, 12:10 am
From: Fayaz Aziz <fayaz.a...@gmail.com>
Date: Mon, 30 Jul 2012 21:10:14 -0700 (PDT)
Local: Tues, Jul 31 2012 12:10 am
Subject: Re: simple udf implementation in 'select' clause not working but working in 'where' clause

hmmm okay but the problem is that i need to perform io calls.. here is the
flow of my work which i was trying to perform for last 2 weeks and haven't
succeeded yet.

1) call sqoot api to retrieve 10 records by passing parameter : 1)location
2) for each records gets marchant_name , latitude and longitude and call
google api to get the exact locations by passing params 1) merchant name 2)
latitude 3) longitude
3) from the result of 2) modify the result and construct an object i.e

loc : [0:'5464654',1:'46546546'] // where 0 means latitude value and 1
means longitude value

4) select few results from 1) and replace location from that with the one
we construct in 3)
5) return the dataset to any controller / function which will processed
further..

here is what i have tried till now :

1) ql.io query which is joining both the tables having *multiple join
predicates* as column - which is failed i.e for now when using join only
the next condition after where clause consider as joining clause, all
remaining will consider as conditional clause

2) i tried this for udf... the preferred ways was to call a udf function in
select clause so that we have correct values in parameter and than we can
call udf function which will do IO operation and return a location result
which will be replace in the select clause by any alias (*udf for select
clause will be release in v0.9*)

3)  i then tried to use monkey patch but since we are doing IO operations
which is *async calls* so sqoot api will not wait for the result of google
api (which is running in patch) so both run simultaneously

both 2 and 3 are not preferred to use for io calls rather its meant to use
for lightweight works like filtering.. data altering..
*
So now since its the earlier releases of q.io keeping in mind the current
capabilities of qlio how can i accomplish my task. ???*


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
shimonchayim  
View profile  
 More options Jul 31 2012, 12:41 pm
From: shimonchayim <shimoncha...@gmail.com>
Date: Tue, 31 Jul 2012 09:41:22 -0700 (PDT)
Local: Tues, Jul 31 2012 12:41 pm
Subject: Re: simple udf implementation in 'select' clause not working but working in 'where' clause

Nothing below sounds to me that needs udf or Monkey Patches for IO.

Here is an example (from ql.io site) where we are doing 1) & 2).

3) & 4) Can be achieved through udfs.

Thats all I can say at this point. This is really not a very complex
example IMHO.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
shimonchayim  
View profile  
 More options Jul 31 2012, 12:42 pm
From: shimonchayim <shimoncha...@gmail.com>
Date: Tue, 31 Jul 2012 09:42:22 -0700 (PDT)
Local: Tues, Jul 31 2012 12:42 pm
Subject: Re: simple udf implementation in 'select' clause not working but working in 'where' clause

Sorry forgot to copy the example:

select e.ItemID as id, e.Title as title, e.ViewItemURLForNaturalSearch as url,
g.geometry.location as latlng
  from details  as e, google.geocode as g
  where e.itemId in (select itemId from finditems where keywords = "iPad")
        and g.address = e.Location


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »