我正在编写一个带有大量重载的VB.NET函数.我已经看到大多数.NET函数在IntelliSense中都有参数描述.例如,在输入时String.Compare(,IntelliSense表示Compares two specified System.String objects and returns...您明白了.此说明更改,您单击相同功能的不同重载版本.当您开始为参数键入内容时,它还会描述您当前正在输入的参数.示例:strA: The first string to compare..
我怎样才能对我的功能进行这样的描述?
假设程序集dll:
using Microsoft.SqlServer.Server;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System;
using System.Text;
namespace CLRFunctions
{
public class T
{
[SqlFunction(DataAccess = DataAccessKind.Read)]
public static String NormalizeString(String s, String normalizationForm)
{
NormalizationForm form = NormalizationForm.FormC;
if (String.Equals(f, "FormD", StringComparison.OrdinalIgnoreCase))
form = NormalizationForm.FormD;
return = s.Normalize(form);
}
}
}
Run Code Online (Sandbox Code Playgroud)
注意:将程序集目标指向.NET 3.5,因为SQL Server不支持.NET 4.0
将程序集复制到一个位置,"创建"程序集工作正常:
CREATE ASSEMBLY CLRFunctions FROM 'c:\Program Files\My App\CLRFunctions.dll';
Run Code Online (Sandbox Code Playgroud)
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO …Run Code Online (Sandbox Code Playgroud) 我有我在MySQL中创建的存储过程,并希望PHP调用该存储过程.做这个的最好方式是什么?
-MySQL客户端版本:
4.1.11 -MySQL Server版本:5.0.45
这是我的存储过程:
DELIMITER $$
DROP FUNCTION IF EXISTS `getNodeName` $$
CREATE FUNCTION `getTreeNodeName`(`nid` int) RETURNS varchar(25) CHARSET utf8
BEGIN
DECLARE nodeName varchar(25);
SELECT name into nodeName FROM tree
WHERE id = nid;
RETURN nodeName;
END $$
DELIMITER ;
Run Code Online (Sandbox Code Playgroud)
调用getTreeNodeName过程的PHP代码是什么?
有没有办法将重复项保存在Hive中的收集集中,或者模拟Hive使用其他方法提供的聚合集合的类型?我想将列中具有相同键的所有项聚合到一个数组中,并重复.
IE:
hash_id | num_of_cats
=====================
ad3jkfk 4
ad3jkfk 4
ad3jkfk 2
fkjh43f 1
fkjh43f 8
fkjh43f 8
rjkhd93 7
rjkhd93 4
rjkhd93 7
Run Code Online (Sandbox Code Playgroud)
应该返回:
hash_agg | cats_aggregate
===========================
ad3jkfk Array<int>(4,4,2)
fkjh43f Array<int>(1,8,8)
rjkhd93 Array<int>(7,4,7)
Run Code Online (Sandbox Code Playgroud) 我知道如何在Spark SQL中编写UDF:
def belowThreshold(power: Int): Boolean = {
return power < -40
}
sqlContext.udf.register("belowThreshold", belowThreshold _)
Run Code Online (Sandbox Code Playgroud)
我可以做类似的定义聚合函数吗?这是怎么做到的?
对于上下文,我想运行以下SQL查询:
val aggDF = sqlContext.sql("""SELECT span, belowThreshold(opticalReceivePower), timestamp
FROM ifDF
WHERE opticalReceivePower IS NOT null
GROUP BY span, timestamp
ORDER BY span""")
Run Code Online (Sandbox Code Playgroud)
它应该返回类似的东西
Row(span1, false, T0)
我希望聚合函数告诉我opticalReceivePower在定义的组中是否有任何值span,timestamp哪些值低于阈值.我是否需要以不同的方式将UDAF写入上面粘贴的UDF?
scala aggregate-functions user-defined-functions apache-spark apache-spark-sql
我在android中开发一个应用程序,我需要在sqlite中创建一个udf.是否可以在sqlite中创建它?如果是的话怎么做?
在用Java编写的OpenOffice/LibreOffice Calc(Spreadsheet)的UNO扩展中,如何确定UDF(电子表格函数)实现中的调用单元?
备注
Application.Caller
这也是Apache OpenOffice Bugzilla上的功能请求
给定一个表值函数,如dbo.Split()从"T-SQL:对面字符串连接-如何将字符串分割成多个记录",我如何通过多行作为参数?
这有效:
SELECT *
FROM dbo.Split
(',', (SELECT myColumn FROM Stuff WHERE id = 22268))
WHERE ISNULL(s,'') <> ''
Run Code Online (Sandbox Code Playgroud)
它返回:
pn s
----------- -----------
1 22351
2 22354
3 22356
4 22357
5 22360
Run Code Online (Sandbox Code Playgroud)
但这不是:
SELECT *
FROM dbo.Split
(',', (SELECT myColumn FROM Stuff))
WHERE ISNULL(s,'') <> ''
Run Code Online (Sandbox Code Playgroud)
这也不是:
SELECT * FROM dbo.Split_temp(',', myColumn), Stuff
Run Code Online (Sandbox Code Playgroud)
文档说:
当在子查询的FROM子句中调用返回表的用户定义函数时,函数参数不能引用外部查询中的任何列.
我正在寻找的那种结果集看起来像:
id pn s
----------- ----------- -----------
22268 1 22351
22268 2 22354
22268 3 22356
22268 4 …Run Code Online (Sandbox Code Playgroud) 我从未使用过数据库函数,但我当前的项目需要它.我需要将一个常见的sql查询放入一个函数中,这样我们就不必在代码中输入数百次了.我已经创建了这个函数,但我不知道如何使用它.
这是功能代码:
USE [DB_NAME]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_GetConfigurationByProfile]
(
@profileName AS NVARCHAR(50)
)
RETURNS TABLE
AS
RETURN
(
-- Fill the table variable with the rows for your result set
SELECT system_settings_groups.ssg_id, system_settings_groups.ssg_name,
system_settings_groups.ssg_parent_group_id, system_settings_names.ssn_name,
system_Settings_names.ssn_display_name, system_settings_values.ssv_value
FROM system_settings_profiles
JOIN system_settings_values
ON system_settings_profiles.ssp_id = system_settings_values.ssv_ssp_id
JOIN system_settings_names
ON system_settings_names.ssn_id = system_settings_values.ssv_ssn_id
JOIN system_settings_groups
ON system_settings_groups.ssg_id = system_settings_names.ssn_ssg_id
WHERE system_settings_profiles.ssp_name = @profileName
)
那我怎么在sql查询中使用它呢?我只使用SELECT fn_GetConfigurationByProfile('DEFAULTPROFILE')吗?
这可能是一个业余问题,但是哦.我需要帮助 :)
Spark现在提供可在数据帧中使用的预定义函数,并且它们似乎已经过高度优化.我最初的问题是更快,但我自己做了一些测试,发现至少在一个实例中,spark函数的速度提高了大约10倍.有谁知道为什么会这样,什么时候udf会更快(仅适用于存在相同spark函数的情况)?
这是我的测试代码(在Databricks社区上运行):
# UDF vs Spark function
from faker import Factory
from pyspark.sql.functions import lit, concat
fake = Factory.create()
fake.seed(4321)
# Each entry consists of last_name, first_name, ssn, job, and age (at least 1)
from pyspark.sql import Row
def fake_entry():
name = fake.name().split()
return (name[1], name[0], fake.ssn(), fake.job(), abs(2016 - fake.date_time().year) + 1)
# Create a helper function to call a function repeatedly
def repeat(times, func, *args, **kwargs):
for _ in xrange(times):
yield func(*args, **kwargs)
data = list(repeat(500000, fake_entry))
print …Run Code Online (Sandbox Code Playgroud) performance user-defined-functions apache-spark apache-spark-sql pyspark
apache-spark ×2
java ×2
sql ×2
sql-server ×2
android ×1
hadoop ×1
hive ×1
libreoffice ×1
mysql ×1
mysqli ×1
performance ×1
php ×1
pyspark ×1
scala ×1
sqlclr ×1
sqlite ×1
t-sql ×1
uno ×1
vb.net ×1