Skip to content

Commit 79894e4

Browse files
committed
modify CREATE STATE sample BQL
1 parent b122dc5 commit 79894e4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v 2.7.9
5454

5555
```python
5656
class SampleClass(object):
57-
def __init__(self, params):
58-
# params is dictionary
57+
def __init__(self, arg1, arg2='arg2', arg3='arg3', **arg4):
58+
# initializing
5959
# blow BQL sample will set like:
60-
# params['v1'] = -1
61-
# params['v2'] = 'string'
60+
# arg1 = 'arg1'
61+
# arg2 = 'arg2' # default value
62+
# arg3 = 'arg3a' # overwritten
63+
# arg4 = {'new_arg1':1, 'new_arg2':'2'} # variable named arguments
6264

63-
def sample_method(self, v1, v2):
65+
def sample_method(self, v1, v2, v3):
6466
# do something
6567

6668
def write_method(self, value):
@@ -76,8 +78,10 @@ CREATE STATE sample_module TYPE pystate
7678
class_name = 'SampleClass', -- required
7779
write_method = 'write_method', -- optional
7880
-- rest parameters are used for initializing constructor arguments.
79-
v1 = -1,
80-
v2 = 'string'
81+
arg1 = 'arg1',
82+
arg3 = 'arg3a',
83+
new_arg1 = 1,
84+
new_arg2 = '2'
8185
;
8286
```
8387

@@ -100,7 +104,7 @@ Those UDS creation query and UDF are same as following python code.
100104
import sample_module
101105

102106
# same as CREATE STATE
103-
sm = sample_module.SampleClass({'v1':-1, 'v2':'string'})
107+
sm = sample_module.SampleClass(arg1='arg1', arg3='arg3a', new_arg1=1, new_arg2='2')
104108

105109
# same as EVAL
106110
sm.sample_method(arg1, arg2, arg3)

0 commit comments

Comments
 (0)