PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: helm/helm (go)

Issue:
Check if Chart is top level Chart or included as dependency
Hi,

is there a way to tell if a Chart is being installed/templated as the top level Chart or included as a dependency of another Chart?

I would like to have everything of the Chart in a named template so that it can be included n-times by a parent Chart dynamically and in case it is installed on its own I would like it to be rendered directly one time so that it can still be installed via helm install.

Thanks in advance.

Pull request:
Make Chart's IsRoot available to templates
**What this PR does / why we need it**:
This PR closes #9991 as it adds the information if the currently processed (templated) Chart is the root or not. This allows to have different behavior in case a Chart is installed on its own or included as part of another Chart. 

Templates can check this flag like so:

```
IsRoot: {{ .Chart.IsRoot }}
```

**Special notes for your reviewer**:
This is my first PR to Helm so please let me know if I'm missing something

**If applicable**:
- [ ] this PR contains documentation
- [x] this PR contains unit tests
- [ ] this PR has been tested for backwards compatibility


Patch:
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go
index 4da64f5cc..7bfb72234 100644
--- a/pkg/engine/engine.go
+++ b/pkg/engine/engine.go
@@ -345,8 +345,13 @@ func allTemplates(c *chart.Chart, vals chartutil.Values) map[string]renderable {
 // As it recurses, it also sets the values to be appropriate for the template
 // scope.
 func recAllTpls(c *chart.Chart, templates map[string]renderable, vals chartutil.Values) {
+	chartMetaData := struct {
+		chart.Metadata
+		IsRoot bool
+	}{*c.Metadata, c.IsRoot()}
+
 	next := map[string]interface{}{
-		"Chart":        c.Metadata,
+		"Chart":        chartMetaData,
 		"Files":        newFiles(c.Files),
 		"Release":      vals["Release"],
 		"Capabilities": vals["Capabilities"],


Test patch:
diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go
index 72ee02626..7f431e75c 100644
--- a/pkg/engine/engine_test.go
+++ b/pkg/engine/engine_test.go
@@ -346,6 +346,36 @@ func TestAllTemplates(t *testing.T) {
 	}
 }
 
+func TestChartValuesContainsIsRoot(t *testing.T) {
+	ch1 := &chart.Chart{
+		Metadata: &chart.Metadata{Name: "parent"},
+		Templates: []*chart.File{
+			{Name: "templates/isroot", Data: []byte("{{.Chart.IsRoot}}")},
+		},
+	}
+	dep1 := &chart.Chart{
+		Metadata: &chart.Metadata{Name: "child"},
+		Templates: []*chart.File{
+			{Name: "templates/isroot", Data: []byte("{{.Chart.IsRoot}}")},
+		},
+	}
+	ch1.AddDependency(dep1)
+
+	out, err := Render(ch1, chartutil.Values{})
+	if err != nil {
+		t.Fatalf("failed to render templates: %s", err)
+	}
+	expects := map[string]string{
+		"parent/charts/child/templates/isroot": "false",
+		"parent/templates/isroot":              "true",
+	}
+	for file, expect := range expects {
+		if out[file] != expect {
+			t.Errorf("Expected %q, got %q", expect, out[file])
+		}
+	}
+}
+
 func TestRenderDependency(t *testing.T) {
 	deptpl := `{{define "myblock"}}World{{end}}`
 	toptpl := `Hello {{template "myblock"}}`
Repository: parquet-go/parquet-go (go)

Issue:
`SortingWriter` do not apply `SkipPageBounds` option
`SkipPageBounds` added in #145. It works well for `GenericWriter[T]` but not working for `SortingWriter[T]` - it still produce min-max values in indexes.


Pull request:
Fix #293 (apply SkipPageBounds to SortingWriter[T])
`SortingWriter[T]` produce `min` / `max` index value even if `SkipPageBounds` option provided. `SkipPageBounds` added in #145.

(#294 was closed by mistake).

Patch:
diff --git a/config.go b/config.go
index 001e08f..fb1e9d9 100644
--- a/config.go
+++ b/config.go
@@ -297,6 +297,7 @@ func (c *WriterConfig) ConfigureWriter(config *WriterConfig) {
 		BloomFilters:         coalesceBloomFilters(c.BloomFilters, config.BloomFilters),
 		Compression:          coalesceCompression(c.Compression, config.Compression),
 		Sorting:              coalesceSortingConfig(c.Sorting, config.Sorting),
+		SkipPageBounds:       coalesceSkipPageBounds(c.SkipPageBounds, config.SkipPageBounds),
 		Encodings:            encodings,
 	}
 }
@@ -845,6 +846,13 @@ func coalesceBloomFilters(f1, f2 []BloomFilterColumn) []BloomFilterColumn {
 	return f2
 }
 
+func coalesceSkipPageBounds(b1, b2 [][]string) [][]string {
+	if b1 != nil {
+		return b1
+	}
+	return b2
+}
+
 func coalesceCompression(c1, c2 compress.Codec) compress.Codec {
 	if c1 != nil {
 		return c1


Test patch:
diff --git a/sorting_test.go b/sorting_test.go
index 796346d..7486706 100644
--- a/sorting_test.go
+++ b/sorting_test.go
@@ -8,6 +8,7 @@ import (
 	"os"
 	"reflect"
 	"slices"
+	"strconv"
 	"testing"
 	"time"
 
@@ -379,3 +380,62 @@ func TestMergedRowsCorruptedString(t *testing.T) {
 		}
 	}
 }
+
+func TestIssue293(t *testing.T) {
+	type Row struct {
+		Value1 string `parquet:"value1"`
+		Value2 string `parquet:"value2"`
+		Value3 string `parquet:"value3"`
+	}
+
+	rows := make([]Row, 10)
+	for i := range rows {
+		rows[i].Value1 = strconv.Itoa(-i)
+		rows[i].Value2 = strconv.Itoa(i)
+		rows[i].Value3 = strconv.Itoa(i * i)
+	}
+
+	buffer := bytes.NewBuffer(nil)
+	writer := parquet.NewSortingWriter[Row](buffer, 9,
+		parquet.SkipPageBounds("value1"),
+		parquet.SkipPageBounds("value3"),
+		parquet.SortingWriterConfig(
+			parquet.SortingColumns(
+				parquet.Ascending("value1"),
+				parquet.Descending("value2"),
+			),
+		),
+	)
+
+	if _, err := writer.Write(rows); err != nil {
+		t.Fatal(err)
+	}
+
+	if err := writer.Close(); err != nil {
+		t.Fatal(err)
+	}
+
+	f, err := parquet.OpenFile(bytes.NewReader(buffer.Bytes()), int64(buffer.Len()))
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	bounds := [][2]string{
+		{"", ""},
+		{"0", "9"},
+		{"", ""},
+	}
+	for i := range 3 {
+		stats := f.Metadata().RowGroups[0].Columns[i].MetaData.Statistics
+
+		min := string(stats.MinValue)
+		if bounds[i][0] != min {
+			t.Fatalf("wrong `min` value in column %d, expected %q, actual %q", i, bounds[i][0], min)
+		}
+
+		max := string(stats.MaxValue)
+		if bounds[i][1] != max {
+			t.Fatalf("wrong `max` value in column %d, expected %q, actual %q", i, bounds[i][1], max)
+		}
+	}
+}