微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Azure ML中的参数化SQL查询

如何解决Azure ML中的参数化SQL查询

背景:似乎有一种使用DataPath参数化PipelineParameter方法 https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/machine-learning-pipelines/intro-to-pipelines/aml-pipelines-showcasing-datapath-and-pipelineparameter.ipynb

但是我想用PipelineParameter参数化我的SQL查询,例如,与此查询

sql_query = """
SELECT id,foo,bar FROM baz
WHERE baz.id BETWEEN 10 AND 20
"""
dataset = Dataset.Tabular.from_sql_query((sql_datastore,sql_query))

我想使用PipelineParameter将1020参数化为param_1param_2。这可能吗?

解决方法

找到了一种方法:

将参数传递给PythonScriptStep

root@ip-172-30-244-157:/home/ubuntu# 
root@ip-172-30-244-157:/home/ubuntu# python
Python 2.7.17 (default,Sep 30 2020,13:38:04) 
[GCC 7.5.0] on linux2
Type "help","copyright","credits" or "license" for more information.

>>> import faker
>>> 
>>> exit()
root@ip-172-30-244-157:/home/ubuntu# 
root@ip-172-30-244-157:/home/ubuntu# 
root@ip-172-30-244-157:/home/ubuntu# exit
exit
ubuntu@ip-172-30-244-157:~$ 
ubuntu@ip-172-30-244-157:~$ 
ubuntu@ip-172-30-244-157:~$ python
Python 2.7.17 (default,"credits" or "license" for more information.
>>> import faker
Traceback (most recent call last):
  File "<stdin>",line 1,in <module>
ImportError: No module named faker
>>> 

在script.py

param_1 = PipelineParameter(name='min_id',default_value=5)
param_2 = PipelineParameter(name='max_id',default_value=10)
sql_datastore = "sql_datastore"
step = PythonScriptStep(script_name='script.py',arguments=[param_1,param_2,sql_datastore])

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。