Preheat oven to 350 degrees. Grease a 12 inch cast iron skillet.
To make the cornbread:
In a mixing bowl, whisk together the butter, sugar, eggs, and buttermilk until smooth. Add the corn, green chiles, and cheese, stirring until combined. Mix in the flour, cornmeal, baking powder, and salt until fully incorporated. Spread the batter into the cast iron skillet. Bake 15-20 minutes, or until set in the center and golden. Using the end of a wooden spoon, poke holes all over the top of the cornbread. Set aside.
Increase oven temperature to 400.
To make the filling:
Heat the oil in a skillet or pot over medium heat. Saute the onions, jalapeño, and garlic until tender, about 3-4 minutes. Add the chili powder, cumin, sugar, and salt and stir in the pan for another minute so that the spices can get slightly toasted and fragrant. Add the tomato sauce and water. Bring the sauce to a simmer and cook 5 minutes. Taste for seasoning and adjust salt as needed. Stir in the shredded chicken and the pinto beans.
To assemble pie:
Using a ladle, scoop the chicken and bean filling mixture evenly over the cornbread. Sprinkle with cheese. Return the skillet to the oven and bake until bubbly and melted, about 15-20 minutes. Serve promptly with cilantro, green onions, sour cream, and avocado on top.