user-defined-functions

User-defined operators in Fortran

假如想象 提交于 2019-12-23 15:26:42
问题 I had a question about the correct way of programming user-defined operators in Fortran. To be more specific, I will provide the example of my problem. I am working on creating a user-defined data type for spherical particles called 'Particle'. I want to define an operator that takes an existing array of Particle objects and adds a new Particle object to it. I was wondering how I would go about defining user defined operators to do such an action. Currently I have, within the type definition

Passing two columns to a udf in scala?

心不动则不痛 提交于 2019-12-23 15:06:41
问题 I have a dataframe containing two columns,one is data and the other column is character count in that data field. Data Count Hello 5 How 3 World 5 I want to change value of column data based on the value in count column. How can this be achieved? I tried this using an udf : invalidrecords.withColumn("value",appendDelimiterError(invalidrecords("value"),invalidrecords("a_cnt"))) This seems to fail, is this the correct way to do it? 回答1: Here's an easy way of doing it first you create a

What can I do to improve performance of my pure User Defined Function in SQL Server?

不羁岁月 提交于 2019-12-23 14:38:11
问题 I have made a simple, but relatively computationally complex, UDF that queries a rarely changing table. In typical usage this function is called many many times from a WHERE clauses over a very small domain of parameters. What can I do to make my usage of the UDF faster? My thoughts are that there should be some way to tell SQL Server that my function returns the same result with the same parameters and thus should be memoized. There doesn't seem a way to do it within the UDF because they are

Passing a range to Excel User Defined Function and assigning it to an array

橙三吉。 提交于 2019-12-23 11:58:01
问题 I am trying to pass two ranges - multiple rows single column - to a user defined function in Excel 2007, then assign it to an array for processing. Can anybody tell me how to assign such range to an array? The range is not constant as I am using an UDF in different cells for different data so I cannot use e,g, Range("A1:A10") The code is working when I just use Data1.Rows.Cells(i, 1) instead of arrays. But I think it is better to use one dimensional arrays for efficiency. Here is my current

How to return complex types using spark UDFs

北慕城南 提交于 2019-12-23 11:51:23
问题 Hello and thank you in advance. My program is written in java and i can not move to scala. I am currently working with a spark DataFrame extracted from a json file using the following line: DataFrame dff = sqlContext.read().json("filePath.son"); SQLContext and SparkContext are correctly initialzied and running perfectly. The problem is the json i'm reading from has nested structs, and I want to clean/verify the inner data, without changing the schema. One of the dataframe's columns in

How do I create a SQL Function to return a BIT?

谁说我不能喝 提交于 2019-12-23 08:51:57
问题 I am using this script below to create a function but I get an error in the messages log: CREATE FUNCTION [dbo].[MyFunction] () RETURNS BIT AS RETURN CAST(1 AS BIT) Msg 102, Level 15, State 31, Procedure MyFunction, Line 1 Incorrect syntax near 'RETURN'. It works when I change this to return a table: CREATE FUNCTION [dbo].[MyFunction] () RETURNS TABLE AS RETURN (SELECT 1 [1]) so I am not sure what is wrong. Why does this work for a table but not a bit? 回答1: Change your syntax to include a

Apache pig script, Error 1070: Java UDF could not resolve import

拈花ヽ惹草 提交于 2019-12-23 05:59:29
问题 I am trying to write a Java UDF with the end goal of extending/overriding the load method of PigStorage to support entries that take multiple lines. My pig script is as follows: REGISTER udf.jar; register 'userdef.py' using jython as parser; A = LOAD 'test_data' USING PigStorage() AS row:chararray; C = FOREACH A GENERATE myTOKENIZE.test(); DUMP D; udf.jar looks like: udf/myTOKENIZE.class myTOKENIZE.java imports org.apache.pig.* ande extends EvalFunc. the test method just returns a Hello world

JSON Array field handling in Elephant-Bird UDF in PIG

我只是一个虾纸丫 提交于 2019-12-23 03:29:37
问题 A quick question on the JSON handling in PIG. I tried some JsonLoader called Elephant-Bird to load and handle JSON data like the followings: { "SV":1, "AD":[ { "ID":"46931606", "C1":"46", "C2":"469", "ST":"46931", "PO":1 }, { "ID":"46721489", "C1":"46", "C2":"467", "ST":"46721", "PO":5 } ] } The loader works well for simple fields but it doesn't work well for any array field. I don't know how I can access elements in the array ("AD" field above) with this UDF or in any other way? Please

Curried UDF - Pyspark

北城以北 提交于 2019-12-22 17:55:05
问题 I am trying to implement a UDF in spark; that can take both a literal and column as an argument. To achieve this, I believe I can use a curried UDF. The function is used to match a string literal to each value in the column of a DataFrame . I have summarized the code below:- def matching(match_string_1): def matching_inner(match_string_2): return difflib.SequenceMatcher(None, match_string_1, match_string_2).ratio() return matching hc.udf.register("matching", matching) matching_udf = F.udf

Performance and usage of CLR functions in SQL

只谈情不闲聊 提交于 2019-12-22 12:54:20
问题 SQL Server allows you to create CLR functions, stored procedures, user types and other objects, for purpose that are really complex to be done inside SQL. But, can someone compare those two things: TSQL Object and CLR Object, in sense of performance, benefits, and so on. What are real situations for usage CLR objects? Is there any best practices proposition for their usage? 回答1: What are real situations for usage CLR objects? SQL Server lacks an aggregate string concatenation function. This