user-defined-functions

Overriding a JavaScript function while referencing the original

眉间皱痕 提交于 2019-12-27 10:19:13
问题 I have a function, a() , that I want to override, but also have the original a() be performed in an order depending on the context. For example, sometimes when I'm generating a page I'll want to override like this: function a() { new_code(); original_a(); } and sometimes like this: function a() { original_a(); other_new_code(); } How do I get that original_a() from within the over-riding a() ? Is it even possible? Please don't suggest alternatives to over-riding in this way, I know of many. I

Reading a file in javascript via Apache Pig UDF

删除回忆录丶 提交于 2019-12-25 11:56:36
问题 I have some (very simplified) nodejs code here: var fs = require('fs'); var derpfile = String(fs.readFileSync( './derp.txt', 'utf-8' )); var derps = derpfile.split( '\n' ); for (var i = 0; i < derps.length; ++i) { // do something with my derps here } The problem is, I cannot use node in Pig UDF's (that I am aware of; if I can do this, please let me know!). When I look at 'file io' in javascript, all the tutorials I see are in re the browser sandbox. I need to read a file off the filesystem,

How to create different files for each time a function is performed on an item in a for loop?

空扰寡人 提交于 2019-12-25 08:48:42
问题 So building off of a code below that a community member here helped me fine-tune to create a function that takes a dictionary value from a text file and looks then looks through that value for a list of files. This was the code where I was appending all the values found to the same sheet. import csv import glob import ast from os.path import isfile from lxml import etree def look_for_speaker_in_files(speakerAttrib): speakerDict = ast.literal_eval(speakerAttrib) l_file_exists = False if isfile

Biqquery quota limits on UDF

半世苍凉 提交于 2019-12-25 05:09:35
问题 Concurrent rate limit for queries that contain user-defined functions (UDFs): 6 concurrent queries, including both interactive and batch queries. Interactive queries that contain UDFs count toward the concurrent rate limit for interactive queries. https://cloud.google.com/bigquery/quota-policy#queries My question. The limit is 6 concurrent queries containing UDF. Is this limits means not more then 6 different queries containing UDF or one query contain UDF can't run Concurrently more then 6

Is there a Spark built-in that flattens nested arrays?

天涯浪子 提交于 2019-12-25 02:29:01
问题 I have a DataFrame field that is a Seq[Seq[String]] I built a UDF to transform said column into a column of Seq[String]; basically, a UDF for the flatten function from Scala. def combineSentences(inCol: String, outCol: String): DataFrame => DataFrame = { def flatfunc(seqOfSeq: Seq[Seq[String]]): Seq[String] = seqOfSeq match { case null => Seq.empty[String] case _ => seqOfSeq.flatten } df: DataFrame => df.withColumn(outCol, udf(flatfunc _).apply(col(inCol))) } My use case is strings, but

SQL Server 2008 R2 - Scalar UDF results in infinite loop

我只是一个虾纸丫 提交于 2019-12-24 17:50:21
问题 The following code is resulting in an infinite loop or really really slow execution: CREATE FUNCTION [dbo].[CleanUriPart] ( -- Add the parameters for the function here @DirtyUriPart nvarchar(200) ) RETURNS nvarchar(200) AS BEGIN; -- Declare the return variable here DECLARE @Result nvarchar(200); DECLARE @i int; SET @i = 1; WHILE 1 = 1 BEGIN; SET @i = PATINDEX('%[^a-zA-Z0-9.~_-]%', @DirtyUriPart COLLATE Latin1_General_BIN); IF @i > 0 SET @DirtyUriPart = STUFF(@DirtyUriPart, @i, 1, '-'); ELSE

Excel user defined function if cell is highlighted then

房东的猫 提交于 2019-12-24 13:58:23
问题 I have created a user defined function to determine whether cells are highlighted a particular color, and it works in some situations, but not the one I need; Basically it works when that cell is permanently highlighted that color but I am basing it on conditional formatting and the function doesn't work if the cell is that color due to conditional formatting. Public Function Active(Rng As Range) As Boolean If Rng.Interior.Color = RGB(217, 151, 149) _ Then Active = True End Function Any help

Using Dynamic SQL in User Defined Function to return string (not modify data)

只愿长相守 提交于 2019-12-24 10:29:55
问题 Our document storage application has a unique database for each of our clients which are almost identical to each other, but one table DocumentIndexes is unique for each client and can have any number of columns and types. I am trying to create a generic function (within our "master" database called MYAPP_MASTER ) that I can call and simply pass in a database name and a document ID value and get back the column names and values from from the specified database's DocumentIndexes table. Because

How do I supply the FROM clause of a SELECT statement from a UDF parameter

回眸只為那壹抹淺笑 提交于 2019-12-24 07:35:44
问题 In the application I'm working on porting to the web, we currently dynamically access different tables at runtime from run to run, based on a "template" string that is specified. I would like to move the burden of doing that back to the database now that we are moving to SQL server, so I don't have to mess with a dynamic GridView. I thought of writing a Table-valued UDF with a parameter for the table name and one for the query WHERE clause. I entered the following for my UDF but obviously it

How to apply a derived column list (table and column aliases) to a table valued function call in SQL Server

不问归期 提交于 2019-12-24 05:45:13
问题 I'm emulating PostgreSQL style generate_series() table-valued functions in SQL Server as such: CREATE FUNCTION generate_series(@d1 DATE, @d2 DATE) RETURNS TABLE AS RETURN -- Ignore implementation (returning a single DATE column) for this question This can now be used as expected: SELECT * FROM generate_series( CAST ('2005-07-01' AS DATE), CAST ('2005-07-31' AS DATE) ) t Now I'd like to use derived column list syntax to rename columns along with the table as such: SELECT * FROM generate_series