Changeset: e88eff841612 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e88eff841612
Modified Files:
monetdb5/modules/mal/sample.mal
sql/server/sql_parser.y
Branch: sample-with-seed
Log Message:
Make sure that sampling (with seed) works for both relative and absolute
sample parameters.
diffs (83 lines):
diff --git a/monetdb5/modules/mal/sample.mal b/monetdb5/modules/mal/sample.mal
--- a/monetdb5/modules/mal/sample.mal
+++ b/monetdb5/modules/mal/sample.mal
@@ -18,8 +18,12 @@ comment "Returns the oids of a uniform s
pattern subuniform(b:bat[:any],sample_size:lng,sample_seed:int):bat[:oid]
address SAMPLEuniform
-comment "Returns the oids of a uniform sample of size s";
+comment "Returns the oids of a uniform sample of size s and where the prg is
seeded with sample_seed";
pattern subuniform(b:bat[:any],p:dbl):bat[:oid]
address SAMPLEuniform
comment "Returns the oids of a uniform sample of size = (p x count(b)), where
0 <= p <= 1.0";
+
+pattern subuniform(b:bat[:any],p:dbl,sample_seed:int):bat[:oid]
+address SAMPLEuniform
+comment "Returns the oids of a uniform sample of size = (p x count(b)), where
0 <= p <= 1.0 and where the prg is seeded with sample_seed";
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -243,6 +243,7 @@ int yydebug=1;
opt_limit
opt_offset
opt_sample
+ opt_seed
param
case_exp
case_scalar_exp
@@ -3590,39 +3591,38 @@ opt_offset:
opt_sample:
/* empty */ { $$ = NULL; }
- | SAMPLE poslng {
+ | SAMPLE poslng opt_seed {
dlist *l = L();
append_symbol(l,
_newAtomNode( atom_int(SA,
sql_bind_localtype("lng"), $2)) );
+ if ($3)
+ append_symbol(l,$3);
+
$$ = _symbol_create_list(SQL_SAMPLE, l);
}
- | SAMPLE INTNUM {
+ | SAMPLE INTNUM opt_seed {
dlist *l = L();
append_symbol(l,
_newAtomNode( atom_float(SA,
sql_bind_localtype("dbl"), strtod($2,NULL))) );
+
+ if ($3)
+ append_symbol(l,$3);
$$ = _symbol_create_list(SQL_SAMPLE, l);
}
| SAMPLE param { $$ = $2; }
-
- | SAMPLE poslng SEED intval {
-
- dlist *l = L();
-
- append_symbol(l,
- _newAtomNode( atom_int(SA,
sql_bind_localtype("lng"), $2)) );
-
- append_symbol(l,
- _newAtomNode( atom_int(SA,
sql_bind_localtype("int"), $4)) );
-
- $$ = _symbol_create_list(SQL_SAMPLE, l);
- }
- ;
+ ;
+
+ opt_seed:
+ /* empty */ { $$ = NULL; }
+ | SEED intval {
+ $$ = _newAtomNode( atom_int(SA,
sql_bind_localtype("int"), $2));
+ }
sort_specification_list:
ordering_spec { $$ = append_symbol(L(), $1); }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list