nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: brimsec/zq
Pull request #2405 (2021-03-24 03:48:30)

fix handling of negative durations in zson.Lexer


Patch:
diff --git a/zson/lexer.go b/zson/lexer.go
index d5fa002de..e6e31c1e8 100644
--- a/zson/lexer.go
+++ b/zson/lexer.go
@@ -14,7 +14,7 @@ import (
 
 var ErrBufferOverflow = errors.New("zson scanner buffer size exceeded")
 
-const primitiveRE = `^(([0-9a-fA-Fx_\$\-\+:eEnumsh./TZµ]+)|true|false|null|-Inf|-inf|\+Inf|\+inf|NaN|nan|(([.0-9]+(ns|us|ms|s|m|h|d|w|y))+))`
+const primitiveRE = `^(([0-9a-fA-Fx_\$\-\+:eEnumsh./TZµ]+)|true|false|null|-Inf|-inf|\+Inf|\+inf|NaN|nan|(([-.0-9]+(ns|us|ms|s|m|h|d|w|y))+))`
 const indentationRE = `\n\s*`
 
 type Lexer struct {


Test patch:
diff --git a/zson/ztests/negative-duration.yaml b/zson/ztests/negative-duration.yaml
new file mode 100644
index 000000000..1e8bdb38c
--- /dev/null
+++ b/zson/ztests/negative-duration.yaml
@@ -0,0 +1,6 @@
+zql: '*'
+
+input: &input |
+  {duration:-292y171d23h47m16.854775807s}
+
+output: *input
Repository: brimsec/zq
Pull request #2432 (2021-03-26 13:44:39)

fix locking bug in zson context
This commit fixes a bug where unlock was called on an unlocked lock.

This was triggered when a typedef name was accessed that did
not yet exist.  We added a test to exercise this path with an
issue() function that looks for a type that is not defuned until
the second record in the input.


Patch:
diff --git a/zson/context.go b/zson/context.go
index 0594596d0..c52dd187e 100644
--- a/zson/context.go
+++ b/zson/context.go
@@ -254,10 +254,10 @@ func (c *Context) LookupByName(zson string) (zng.Type, error) {
 	// each component of a nested type.
 	c.mu.Unlock()
 	typ, err := ParseType(c, zson)
+	c.mu.Lock()
 	if err != nil {
 		return nil, err
 	}
-	c.mu.Lock()
 	// ParseType will ensure the canonical zson is in the toType table,
 	// but the zson argument here may be any conforming zson type string.
 	// Since this string may appear repeatedly (e.g., type values


Test patch:
diff --git a/expr/ztests/is-late-binding.yaml b/expr/ztests/is-late-binding.yaml
new file mode 100644
index 000000000..15d8c8945
--- /dev/null
+++ b/expr/ztests/is-late-binding.yaml
@@ -0,0 +1,11 @@
+zql: is(type(foo))
+
+input: |
+  {x:1}
+  {x:2} (=foo)
+  {x:3}
+  {x:4} (foo)
+
+output: |
+  {x:2} (=foo)
+  {x:4} (foo)